Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7d97d31a
Commit
7d97d31a
authored
Jan 28, 2003
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OK, this is really the last one tonight!
NEWFALSE and NEWTRUE.
parent
025bc2fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
Lib/pickle.py
Lib/pickle.py
+12
-1
Lib/test/pickletester.py
Lib/test/pickletester.py
+7
-0
No files found.
Lib/pickle.py
View file @
7d97d31a
...
...
@@ -356,7 +356,10 @@ class Pickler:
dispatch
[
NoneType
]
=
save_none
def
save_bool
(
self
,
object
):
self
.
write
(
object
and
TRUE
or
FALSE
)
if
self
.
proto
>=
2
:
self
.
write
(
object
and
NEWTRUE
or
NEWFALSE
)
else
:
self
.
write
(
object
and
TRUE
or
FALSE
)
dispatch
[
bool
]
=
save_bool
def
save_int
(
self
,
object
,
pack
=
struct
.
pack
):
...
...
@@ -760,6 +763,14 @@ class Unpickler:
self
.
append
(
None
)
dispatch
[
NONE
]
=
load_none
def
load_false
(
self
):
self
.
append
(
False
)
dispatch
[
NEWFALSE
]
=
load_false
def
load_true
(
self
):
self
.
append
(
True
)
dispatch
[
NEWTRUE
]
=
load_true
def
load_int
(
self
):
data
=
self
.
readline
()
if
data
==
FALSE
[
1
:]:
...
...
Lib/test/pickletester.py
View file @
7d97d31a
...
...
@@ -293,6 +293,13 @@ class AbstractPickleTests(unittest.TestCase):
y
=
self
.
loads
(
s
)
self
.
assertEqual
(
x
,
y
,
(
proto
,
x
,
s
,
y
))
def
test_singletons
(
self
):
for
proto
in
0
,
1
,
2
:
for
x
in
None
,
False
,
True
:
s
=
self
.
dumps
(
x
,
proto
)
y
=
self
.
loads
(
s
)
self
.
assert_
(
x
is
y
,
(
proto
,
x
,
s
,
y
))
class
AbstractPickleModuleTests
(
unittest
.
TestCase
):
def
test_dump_closed_file
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment