[ python-Bugs-1281383 ] array.arrays are not unpickleable

SourceForge.net noreply at sourceforge.net
Sat Sep 3 22:16:53 CEST 2005


Bugs item #1281383, was opened at 2005-09-03 22:16
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1281383&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: Python 2.4
Status: Open
Resolution: None
Priority: 6
Submitted By: Reinhold Birkenfeld (birkenfeld)
Assigned to: Raymond Hettinger (rhettinger)
Summary: array.arrays are not unpickleable

Initial Comment:
Credits to John Machin for discovering this.

"""
Googling for "pickle array" in comp.lang.python yields
old messages that 
show a PickleError -- plus one message where Alex
Martelli writes "I am 
but an egg" :O)
Looks like arrays are NOW (2.4.1) pickleable but not
unpickleable -- see 
below.
I appreciate that arrays are inherently not pickleable
because of the 
type code.
However:
(1) Anyone know why/when the world changed?
(2) If we had alternative constructors like
array.iarray(contents) in 
parallel to array.array('i', contents), those objects
could be 
pickled/unpickled -- yes/no?

Cheers,
John
====================
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310
32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for
more information.
 >>> import pickle, array
 >>> class Foo(object):
...    pass
...
 >>> foo = Foo()
 >>> foo.ia = array.array('i', [3,2,1])
 >>> foo.ia
array('i', [3, 2, 1])
 >>> s = pickle.dumps(foo, -1)
 >>> bar = pickle.loads(s)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\Python24\lib\pickle.py", line 1394, in loads
    return Unpickler(file).load()
  File "C:\Python24\lib\pickle.py", line 872, in load
    dispatch[key](self)
  File "C:\Python24\lib\pickle.py", line 1097, in
load_newobj
    obj = cls.__new__(cls, *args)
TypeError: array() takes at least 1 argument (0 given)
===========
"""

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1281383&group_id=5470


More information about the Python-bugs-list mailing list