[New-bugs-announce] [issue13103] copy of an asyncore dispatcher causes infinite recursion
Xavier de Gaye
report at bugs.python.org
Tue Oct 4 22:41:19 CEST 2011
New submission from Xavier de Gaye <xdegaye at gmail.com>:
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.
----------
components: Extension Modules
messages: 144925
nosy: xdegaye
priority: normal
severity: normal
status: open
title: copy of an asyncore dispatcher causes infinite recursion
type: behavior
versions: Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13103>
_______________________________________
More information about the New-bugs-announce
mailing list