Message117145
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. |
|
Date |
User |
Action |
Args |
2010-09-22 14:58:07 | jaraco | set | recipients:
+ jaraco, gvanrossum, loewis, nnorwitz, brett.cannon, georg.brandl, facundobatista, jafo, ehuss, tseaver, belopolsky, zseil, alexandre.vassalotti, jarpa, kylev |
2010-09-22 14:58:07 | jaraco | set | messageid: <1285167487.24.0.799498618025.issue1692335@psf.upfronthosting.co.za> |
2010-09-22 14:58:05 | jaraco | link | issue1692335 messages |
2010-09-22 14:58:04 | jaraco | create | |
|