Message82721
The attached short file causes all of python 2.5, 2.6 and 3.0 to drop
into infinite recursion trying to unpickle the created object, but the
2.5 version has the cleanest The problem appears to be that the unpickle
code (C in 3.0; Python in 2.5 - I assume the others are similar) uses
getattr to try and get the __setstate__ method (if any) of the opject
being built before it's dictionary is populated. This causes the
invocation of the __getattr__ method, which tries to use the
non-existent "attrs" attribute, thus starting the recursion.
A simple workaround is to provide this:
def __setstate__(self, data):
self.__dict__.update(data)
but methinks that either 1) the interpreter shouldn't be falling into
the infinite loop in this case, or 2) the pickle code should be using
hasattr to check for the attribute (which won't trigger this problem)
before trying getattr on it. |
|
Date |
User |
Action |
Args |
2009-02-25 21:26:17 | mwm | set | recipients:
+ mwm |
2009-02-25 21:26:16 | mwm | set | messageid: <1235597176.48.0.557535954175.issue5370@psf.upfronthosting.co.za> |
2009-02-25 21:26:14 | mwm | link | issue5370 messages |
2009-02-25 21:26:12 | mwm | create | |
|