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
cf117b0b
Commit
cf117b0b
authored
Feb 09, 2003
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename 'proto' keyword arg to 'protocol' . Greg Ward's suggestion.
parent
d58f3fce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
17 deletions
+17
-17
Lib/pickle.py
Lib/pickle.py
+17
-17
No files found.
Lib/pickle.py
View file @
cf117b0b
...
...
@@ -167,11 +167,11 @@ del x
class
Pickler
:
def
__init__
(
self
,
file
,
proto
=
None
,
bin
=
None
):
def
__init__
(
self
,
file
,
proto
col
=
None
,
bin
=
None
):
"""This takes a file-like object for writing a pickle data stream.
The optional proto
argument tells the pickler to use the given
protocol; supported protocols are 0, 1, 2. The default
The optional proto
col argument tells the pickler to use the
given
protocol; supported protocols are 0, 1, 2. The default
protocol is 0, to be backwards compatible. (Protocol 0 is the
only protocol that can be written to a file opened in text
mode and read back successfully. When using a protocol higher
...
...
@@ -191,22 +191,22 @@ class Pickler:
object, or any other custom object that meets this interface.
"""
if
proto
is
not
None
and
bin
is
not
None
:
raise
ValueError
,
"can't specify both 'proto
' and 'bin' arguments
"
if
proto
col
is
not
None
and
bin
is
not
None
:
raise
ValueError
,
"can't specify both 'proto
col' and 'bin'
"
if
bin
is
not
None
:
warnings
.
warn
(
"The 'bin' argument to Pickler() is deprecated"
,
PendingDeprecationWarning
)
proto
=
bin
if
proto
is
None
:
proto
=
0
if
proto
<
0
:
proto
=
2
elif
proto
not
in
(
0
,
1
,
2
):
proto
col
=
bin
if
proto
col
is
None
:
proto
col
=
0
if
proto
col
<
0
:
proto
col
=
2
elif
proto
col
not
in
(
0
,
1
,
2
):
raise
ValueError
,
"pickle protocol must be 0, 1 or 2"
self
.
write
=
file
.
write
self
.
memo
=
{}
self
.
proto
=
int
(
proto
)
self
.
bin
=
proto
>=
1
self
.
proto
=
int
(
proto
col
)
self
.
bin
=
proto
col
>=
1
self
.
fast
=
0
def
clear_memo
(
self
):
...
...
@@ -1369,12 +1369,12 @@ try:
except
ImportError
:
from
StringIO
import
StringIO
def
dump
(
obj
,
file
,
proto
=
None
,
bin
=
None
):
Pickler
(
file
,
proto
,
bin
).
dump
(
obj
)
def
dump
(
obj
,
file
,
proto
col
=
None
,
bin
=
None
):
Pickler
(
file
,
proto
col
,
bin
).
dump
(
obj
)
def
dumps
(
obj
,
proto
=
None
,
bin
=
None
):
def
dumps
(
obj
,
proto
col
=
None
,
bin
=
None
):
file
=
StringIO
()
Pickler
(
file
,
proto
,
bin
).
dump
(
obj
)
Pickler
(
file
,
proto
col
,
bin
).
dump
(
obj
)
return
file
.
getvalue
()
def
load
(
file
):
...
...
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