1 message in org.python.python-bugs-list[ python-Bugs-910986 ] copy.copy fail...
FromSent OnAttachments
SourceForge.netMar 13, 2004 1:37 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[ python-Bugs-910986 ] copy.copy fails for array.arrayActions...
From:SourceForge.net (nore@sourceforge.net)
Date:Mar 13, 2004 1:37:56 pm
List:org.python.python-bugs-list

Bugs item #910986, was opened at 2004-03-06 11:03 Message generated for change (Comment added) 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: Closed Resolution: Fixed

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(&#039;c&#039;, &#039;abcdef&#039;) 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.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)

Date: 2004-03-13 13:28

Message: Logged In: YES user_id=80475

Okay, added support for the copy module.

See Modules/arraymodule.c 2.93

----------------------------------------------------------------------