New submission from ThomasH <thomas.bugzi...@gmx.net>: 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__. ---------- components: Library (Lib) messages: 89985 nosy: ThomasH severity: normal status: open title: Add Pickle Support to the codecs Module type: crash versions: Python 2.5, Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6395> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com