Message144925
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. |
|
Date |
User |
Action |
Args |
2011-10-04 20:41:20 | xdegaye | set | recipients:
+ xdegaye |
2011-10-04 20:41:19 | xdegaye | set | messageid: <1317760879.94.0.397539088986.issue13103@psf.upfronthosting.co.za> |
2011-10-04 20:41:19 | xdegaye | link | issue13103 messages |
2011-10-04 20:41:18 | xdegaye | create | |
|