This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ThomasH
Recipients ThomasH
Date 2009-07-01.15:46:25
SpamBayes Score 2.1368339e-07
Marked as misclassified No
Message-id <1246463188.35.0.320675118154.issue6395@psf.upfronthosting.co.za>
In-reply-to
Content
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__.
History
Date User Action Args
2009-07-01 15:46:29ThomasHsetrecipients: + ThomasH
2009-07-01 15:46:28ThomasHsetmessageid: <1246463188.35.0.320675118154.issue6395@psf.upfronthosting.co.za>
2009-07-01 15:46:26ThomasHlinkissue6395 messages
2009-07-01 15:46:25ThomasHcreate