[ python-Bugs-910986 ] copy.copy fails for array.array
SourceForge.net
noreply at sourceforge.net
Sun Mar 7 02:09:39 EST 2004
Bugs item #910986, was opened at 2004-03-06 11:03
Message generated for change (Settings changed) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=910986&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Glenn Parker (redandgray)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: copy.copy fails for array.array
Initial Comment:
Python version 2.3.3 under WindowsXP Home Edition
The standard library "copy" does not work with the
standard library "array".
import copy
import array
x = array.array('c', 'abcdef')
y = copy.copy(x)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/copy.py", line 95, in copy
return _reconstruct(x, rv, 0)
File "/usr/lib/python2.3/copy.py", line 338, in
_reconstruct
y = callable(*args)
File "/usr/lib/python2.3/copy_reg.py", line 92, in
__newobj__
return cls.__new__(cls, *args)
TypeError: array() takes at least 1 argument (0 given)
The same thing happens for copy.deepcopy.
Judging from the TypeError details, it appears that
copy.copy assumes a new object of the same type as its
input argument can be created with no arguments, but
array.array requires at least one argument (describing
the type of items in the array).
array.array should have a custom method added to make
it work smoothly with copy.copy.
Documentation for copy.copy should be clearer about the
requirements on the type of its input argument.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=910986&group_id=5470
More information about the Python-bugs-list
mailing list