Message108954
The case in msg76028 are probably not pointing to a bug. If subclass' __init__ passes its args to the base class __init__ (as it probably should), pickling works:
class E(Exception):
"""Extension with values, init called with args."""
def __init__(self, foo):
self.foo = foo
Exception.__init__(self, foo)
>>> from pickle import *
>>> loads(dumps(E(1)))
E(1,)
>>> _.foo
1
What would be a use case for not setting args? Even if there was a valid use case for it, it would be easy to simply provide custom __getinitargs__ or __reduce__ to support it.
Note that with msg76028 definitions, eval(repr(C('foo'))) also raises a TypeError, so properly supporting args hiding in exception subclasses would probably involve overriding __repr__ as well. |
|
Date |
User |
Action |
Args |
2010-06-29 22:19:01 | belopolsky | set | recipients:
+ belopolsky, gvanrossum, loewis, nnorwitz, brett.cannon, georg.brandl, facundobatista, jafo, ehuss, tseaver, zseil, alexandre.vassalotti, jarpa, kylev |
2010-06-29 22:19:00 | belopolsky | set | messageid: <1277849940.54.0.562826161307.issue1692335@psf.upfronthosting.co.za> |
2010-06-29 22:18:58 | belopolsky | link | issue1692335 messages |
2010-06-29 22:18:58 | belopolsky | create | |
|