Message89985
I recently ran into an infinite recursion trying to unpickle a
codecs.StreamWriter object (I presume the issue would be the same for a
StreamReader).
Here is the end of the stack trace:
File "/sw/lib/python2.5/codecs.py", line 330, in __getattr__
return getattr(self.stream, name)
File "/sw/lib/python2.5/codecs.py", line 330, in __getattr__
return getattr(self.stream, name)
File "/sw/lib/python2.5/codecs.py", line 330, in __getattr__
return getattr(self.stream, name)
RuntimeError: maximum recursion depth exceeded
The issue is the same under Python2.6 but the error output has changed
(see http://bugs.python.org/issue5508).
The problem is that the codecs module tries to delegate member lookup to
the underlying stream. But after unpickling, "self.stream" is not
defined, so the reference to self.stream in __getattr__ itself leads to
an invocation of __getattr__ - hence the recursion loop.
Using tools from the Pickle protocol, like __getstate__/__setstate__,
could help degrade codecs objects gracefully during pickle/unpickle
cycles. E.g. it might be enough to provide a dummy self.stream through
__setstate__. |
|
Date |
User |
Action |
Args |
2009-07-01 15:46:29 | ThomasH | set | recipients:
+ ThomasH |
2009-07-01 15:46:28 | ThomasH | set | messageid: <1246463188.35.0.320675118154.issue6395@psf.upfronthosting.co.za> |
2009-07-01 15:46:26 | ThomasH | link | issue6395 messages |
2009-07-01 15:46:25 | ThomasH | create | |
|