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 xdegaye
Recipients xdegaye
Date 2011-10-04.20:41:18
SpamBayes Score 2.0343756e-09
Marked as misclassified No
Message-id <1317760879.94.0.397539088986.issue13103@psf.upfronthosting.co.za>
In-reply-to
Content
A regression occurs in python 3.2 when doing a copy of an asyncore
dispatcher.

$ python3.1
Python 3.1.2 (r312:79147, Apr  4 2010, 17:46:48) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncore, copy
>>> copy.copy(asyncore.dispatcher())
<asyncore.dispatcher at 0x7fcfb3590e90>


$ python3.2
Python 3.2 (r32:88445, Jun 18 2011, 20:30:18) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncore, copy
>>> copy.copy(asyncore.dispatcher())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.2/copy.py", line 97, in copy
    return _reconstruct(x, rv, 0)
  File "/usr/local/lib/python3.2/copy.py", line 291, in _reconstruct
    if hasattr(y, '__setstate__'):
  File "/usr/local/lib/python3.2/asyncore.py", line 410, in __getattr__
    retattr = getattr(self.socket, attr)
  ....
  File "/usr/local/lib/python3.2/asyncore.py", line 410, in __getattr__
    retattr = getattr(self.socket, attr)
  File "/usr/local/lib/python3.2/asyncore.py", line 410, in __getattr__
    retattr = getattr(self.socket, attr)
RuntimeError: maximum recursion depth exceeded while calling a Python object


This occurs after the 'copy' module has created the new instance with
__new__(). This new instance does not have the 'socket' attribute,
hence the infinite recursion.

Adding the following methods to the dispatcher class, fixes the infinite
recursion:

    def __getstate__(self):
        state = self.__dict__.copy()
        return state

    def __setstate__(self, state):
        self.__dict__.update(state)

But it does not explain why the recursion occurs in 3.2 and not in
3.1.
History
Date User Action Args
2011-10-04 20:41:20xdegayesetrecipients: + xdegaye
2011-10-04 20:41:19xdegayesetmessageid: <1317760879.94.0.397539088986.issue13103@psf.upfronthosting.co.za>
2011-10-04 20:41:19xdegayelinkissue13103 messages
2011-10-04 20:41:18xdegayecreate