Alexander Belopolsky <[email protected]> added the comment:
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.
----------
nosy: +belopolsky
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue1692335>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com