[Python-bugs-list] [ python-Bugs-523020 ] pickle/cPickle Inconsistent EOF handling
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 26 Feb 2002 08:33:42 -0800
Bugs item #523020, was opened at 2002-02-26 08:33
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=523020&group_id=5470
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Thomas W. Christopger (tchristopher)
Assigned to: Nobody/Anonymous (nobody)
Summary: pickle/cPickle Inconsistent EOF handling
Initial Comment:
cPickle.Unpickler(f).load() and cPickle.load() do not
handle EOF the way pickle.Unpickler(f).load(f),
cPickle.loads(s) and pickle.loads(s) do. The first two
give
cPickle.UnpicklingError: invalid load key, ' '.
on EOF. The actual message text is
"invalid load key, '\000'."
The remaining give
EOFError
(The EOFError from all of them is what I need.)
Observe:
>>> pickle.loads('')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python22\lib\pickle.py", line 981, in loads
return Unpickler(file).load()
File "C:\Python22\lib\pickle.py", line 592, in load
dispatch[key](self)
File "C:\Python22\lib\pickle.py", line 606, in
load_eof
raise EOFError
EOFError
>>> cPickle.loads('')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
EOFError
>>> class C:
... def read(self,n): return ''
... def readline(self): return ''
...
>>> p=pickle.Unpickler(C())
>>> p.load()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python22\lib\pickle.py", line 592, in load
dispatch[key](self)
File "C:\Python22\lib\pickle.py", line 606, in
load_eof
raise EOFError
EOFError
>>> pickle.load(C())
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python22\lib\pickle.py", line 977, in load
return Unpickler(file).load()
File "C:\Python22\lib\pickle.py", line 592, in load
dispatch[key](self)
File "C:\Python22\lib\pickle.py", line 606, in
load_eof
raise EOFError
EOFError
>>> p=cPickle.Unpickler(C())
>>> p.load()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
cPickle.UnpicklingError: invalid load key, ' '.
>>> cPickle.load(C())
Traceback (most recent call last):
File "<stdin>", line 1, in ?
cPickle.UnpicklingError: invalid load key, ' '.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=523020&group_id=5470