Message26197
Logged In: YES
user_id=1423362
From the comments, it appears that the developers didn't
notice that the example used protocol '-1' (highest
protocol, which is 2 in Py2.4). Using protocol 0 (default)
or 1 will give the TypeError (which is appropriate).
Using protocol 2, pickle.dumps() will accept a pickle object
without an exception, but it doesn't seem to pickle it
properly (see log below).
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> import array
>>> import pickle
>>> a=array.array('B')
>>> s= pickle.dumps(a,2);s
'\x80\x02carray\narray\nq\x00)\x81q\x01.'
>>> pickle.load(s)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python24\lib\pickle.py", line 1390, in load
return Unpickler(file).load()
File "C:\Python24\lib\pickle.py", line 855, in __init__
self.readline = file.readline
AttributeError: 'str' object has no attribute 'readline'
>>>
>>> a=array.array('B', [1,2,3,4,5])
>>> a
array('B', [1, 2, 3, 4, 5])
>>> s2=pickle.dumps(a,2);s2
'\x80\x02carray\narray\nq\x00)\x81q\x01.' |
|
Date |
User |
Action |
Args |
2007-08-23 14:34:13 | admin | link | issue1281383 messages |
2007-08-23 14:34:13 | admin | create | |
|