mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Charles Waldman writes:
""" In the course of debugging this I also saw that cPickle is inconsistent with pickle - if you attempt a pickle.load or pickle.dump on a closed file, you get a ValueError, whereas the corresponding cPickle operations give an IOError. Since cPickle is advertised as being compatible with pickle, I changed these exceptions to match. """
This commit is contained in:
parent
83addc7a0f
commit
84219682fb
1 changed files with 4 additions and 4 deletions
|
@ -79,18 +79,18 @@ def dotest():
|
|||
f.close()
|
||||
try:
|
||||
cPickle.dump(123, f)
|
||||
except IOError:
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
print "dump to closed file should raise IOError"
|
||||
print "dump to closed file should raise ValueError"
|
||||
f = open(fn, "r")
|
||||
f.close()
|
||||
try:
|
||||
cPickle.load(f)
|
||||
except IOError:
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
print "load from closed file should raise IOError"
|
||||
print "load from closed file should raise ValueError"
|
||||
os.remove(fn)
|
||||
|
||||
# Test specific bad cases
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue