Message169

Author bckfnn
Recipients
Date 2000-11-18.19:38:36
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
This simple code runs in cpython and fails in jpython:

JPython 1.1 on java1.2.2 (JIT: sunwjit)
Copyright (C) 1997-1999 Corporation for National Research Initiatives
>>>import copy
>>>class X: pass
...
>>>x=X()
>>>y=copy.deepcopy(x)
Traceback (innermost last):
  File "<console>", line 1, in ?
  File "/usr/lib/python1.5/copy.py", line 151, in deepcopy
  File "/usr/lib/python1.5/copy.py", line 236, in _deepcopy_inst
  File "/usr/lib/python1.5/copy.py", line 147, in deepcopy
copy.error: un-deep-copyable object of type org.python.core.PyStringMap

I just checked "differences.html", and this isn't in there.

It seems that the problem is that copy.deepcopy doesn't understand
PyStringMap (A special version of dict with only strings for keys?) --
the following seems to fix it:

>>> type(x.__dict__)
<jclass org.python.core.PyStringMap at -2065579726>
>>> import org.python.core
>>> copy._deepcopy_dispatch[org.python.core.PyStringMap] =
copy._deepcopy_dict
>>> copy.deepcopy(x)
<__main__.X instance at -1234058955>

are there other types which will be pitfalls for copy.deepcopy()?
Finn@krause.dk writes:
> - Python instances which are subclasses of java instances.
>   The superclass isn't deepcopied.
> - The bug http://www.python.org/jpython-bugs/incoming?id=118
>   might also cause problems if your data structure have cycles.
History
Date User Action Args
2008-02-20 17:16:43adminlinkissue222859 messages
2008-02-20 17:16:43admincreate