homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jaraco
Recipients alexandre.vassalotti, belopolsky, benjamin.peterson, bpb, brett.cannon, ehuss, facundobatista, fmitha, georg.brandl, gvanrossum, jafo, jaraco, jarpa, kylev, loewis, lukasz.langa, nnorwitz, pitrou, python-dev, sbt, slallum, taleinat, tseaver, vstinner, zbysz, zseil
Date 2018年01月28日.15:04:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1517151891.55.0.467229070634.issue1692335@psf.upfronthosting.co.za>
In-reply-to
Content
@slallum, That does seem to be a problem, though I do observe that the issue reported by bdb with CalledProcessError is no longer an issue:
>>> import subprocess, pickle
>>> try:
... subprocess.check_call(['python', '-c', 'raise SystemExit(1)'])
... except Exception as e:
... pickle.loads(pickle.dumps(e))
... 
CalledProcessError(1, ['python', '-c', 'raise SystemExit(1)'])
Looking into how CalledProcessError is defined (https://github.com/python/cpython/blob/79db11ce99332d62917be9d03b31494b1ff2f96a/Lib/subprocess.py#L60) may shed some light on the recommended way to make a pickleable Exception class that takes more than one argument.
Hmm. It seems it does it by not calling the superclass __init__. Indeed, following that model it seems to work:
import pickle
class MultipleArgumentsError(Exception):
 def __init__(self, a, b):
 self.a = a
 self.b = b
err = pickle.loads(pickle.dumps(MultipleArgumentsError('a', 'b')))
assert err.a == 'a'
assert err.b == 'b'
History
Date User Action Args
2018年01月28日 15:04:51jaracosetrecipients: + jaraco, gvanrossum, loewis, nnorwitz, brett.cannon, georg.brandl, facundobatista, jafo, ehuss, tseaver, belopolsky, zseil, fmitha, pitrou, vstinner, taleinat, alexandre.vassalotti, benjamin.peterson, jarpa, bpb, zbysz, kylev, lukasz.langa, python-dev, sbt, slallum
2018年01月28日 15:04:51jaracosetmessageid: <1517151891.55.0.467229070634.issue1692335@psf.upfronthosting.co.za>
2018年01月28日 15:04:51jaracolinkissue1692335 messages
2018年01月28日 15:04:51jaracocreate

AltStyle によって変換されたページ (->オリジナル) /