Closed jbzdak closed 11 years ago
When I tried deepcopying object containing a JID following error occoured.
In [1]: from sleekxmpp.jid import JID In [2]: from copy import deepcopy In [3]: deepcopy(JID()) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-3-89cd7190e165> in <module>() ----> 1 deepcopy(JID()) /home/jb/.virtualenvs/silf-backend-commons/lib/python3.3/copy.py in deepcopy(x, memo, _nil) 164 reductor = getattr(x, "__reduce_ex__", None) 165 if reductor: --> 166 rv = reductor(2) 167 else: 168 reductor = getattr(x, "__reduce__", None) TypeError: 'NoneType' object is not callable
I have no idea whatsoever what is wrong, but following diff fixes this error:
Index: sleekxmpp/jid.py IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- sleekxmpp/jid.py (date 1361556515000) +++ sleekxmpp/jid.py (date 1380039393000) @@ -21,6 +21,7 @@ from sleekxmpp.util import stringprep_profiles from sleekxmpp.thirdparty import OrderedDict +from copy import deepcopy #: These characters are not allowed to appear in a JID. ILLEGAL_CHARS = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r' + \ @@ -580,3 +581,8 @@ def __copy__(self): """Generate a duplicate JID.""" return JID(self) + + def __deepcopy__(self, memo): + """Generate a duplicate JID.""" + return JID(deepcopy(str(self), memo)) +
Fixed in develop branch.
Thanks for the diff!
When I tried deepcopying object containing a JID following error occoured.
I have no idea whatsoever what is wrong, but following diff fixes this error: