Message26199
Logged In: YES
user_id=1423362
Thatks for catching that. Unfortunatly, that's just a
function of me editing the example. I ment to edit that out
and instead took out the exception I was trying to show.
Here's what I ment to demonstrate:
>>> import array
>>> import pickle
>>> a=array.array('B')
>>> s= pickle.dumps(a,2);s
'\x80\x02carray\narray\nq\x00)\x81q\x01.'
>>> 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)
The part of the problem appears to be with dumps(), as the
same string is returned independent of the array provided:
>>> pickle.dumps(array.array('B'),2)
'\x80\x02carray\narray\nq\x00)\x81q\x01.'
>>> pickle.dumps(array.array('B', [1,2,3,4,5]),2)
'\x80\x02carray\narray\nq\x00)\x81q\x01.'
>>> pickle.dumps(array.array('B', [230,]*100),2)
'\x80\x02carray\narray\nq\x00)\x81q\x01.'
>>> pickle.dumps(array.array('H', [1,2,3,4,5]),2)
'\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 | |
|