mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Implement an idea by Paul Rubin:
Change pickling format for bools to use a backwards compatible encoding. This means you can pickle True or False on Python 2.3 and Python 2.2 or before will read it back as 1 or 0. The code used for pickling bools before would create pickles that could not be read in previous Python versions.
This commit is contained in:
parent
d15a0a05d3
commit
e276339cea
3 changed files with 29 additions and 29 deletions
|
@ -224,5 +224,11 @@ veris(pickle.loads(cPickle.dumps(False)), False)
|
|||
veris(cPickle.loads(pickle.dumps(True)), True)
|
||||
veris(cPickle.loads(pickle.dumps(False)), False)
|
||||
|
||||
# Test for specific backwards-compatible pickle values
|
||||
vereq(pickle.dumps(True), "I01\n.")
|
||||
vereq(pickle.dumps(False), "I00\n.")
|
||||
vereq(cPickle.dumps(True), "I01\n.")
|
||||
vereq(cPickle.dumps(False), "I00\n.")
|
||||
|
||||
if verbose:
|
||||
print "All OK"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue