Jason R. Coombs <jar...@jaraco.com> added the comment:

After some further reading, I found that PEP-352 
(http://www.python.org/dev/peps/pep-0352/) explicitly states that "Including 
programmatic information (e.g., an error code number) should be stored as a 
separate attribute in a subclass [and not in the args attribute]." The 
parameter to Exception.__init__ should always be a single, human-readable 
string. The default pickler doesn't handle this officially-prescribed use-case 
without overriding __reduce__.

class F(Exception):
    def __init__(self, message, code):
        Exception.__init__(self, message)
        self.code = code

Of course, as belopolsky observed, __repr__ must also be overridden.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue1692335>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to