Can't deepcopy bytes-derived class
Dan
daniel.goertzen at gmail.com
Wed Dec 8 14:42:00 EST 2010
I have a simple type derived from bytes...
class atom(bytes):
pass
... that I cannot deepcopy(). The session below demonstrates how
deepcopy() of "bytes" works fine, but deepcopy() of "atom" does not.
What's going wrong?
Thanks,
Dan.
Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit
(Intel)]
Type "help", "copyright", "credits" or "license" for more information.
>>> import copy
>>> class atom(bytes):
... pass
...
>>> copy.deepcopy(b'abc')
b'abc'
>>> copy.deepcopy(atom(b'abc'))
Traceback (most recent call last):
File "C:\Program Files (x86)\Wing IDE 3.2\src\debug\tserver
\_sandbox.py", line 1, in <module>
# Used internally for debug sandbox under external interpreter
File "C:\Python31\Lib\copy.py", line 173, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python31\Lib\copy.py", line 280, in _reconstruct
y = callable(*args)
File "C:\Python31\Lib\copyreg.py", line 88, in __newobj__
return cls.__new__(cls, *args)
builtins.TypeError: string argument without an encoding
>>>
More information about the Python-list
mailing list