Message310951
@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' |
|
Date |
User |
Action |
Args |
2018-01-28 15:04:51 | jaraco | set | recipients:
+ 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:51 | jaraco | set | messageid: <1517151891.55.0.467229070634.issue1692335@psf.upfronthosting.co.za> |
2018-01-28 15:04:51 | jaraco | link | issue1692335 messages |
2018-01-28 15:04:51 | jaraco | create | |
|