summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-02-09 17:19:41 (GMT)
committerGuido van Rossum <guido@python.org>2003-02-09 17:19:41 (GMT)
commitcf117b0b4060a532e13980100c6f94ee98ec2ab1 (patch)
tree6c2b5ec91cdc1962da7d0cfddb16cc6a4dbf75ec /Lib/pickle.py
parentd58f3fce3d1db5b725443788c16f375cb052f4e5 (diff)
downloadcpython-cf117b0b4060a532e13980100c6f94ee98ec2ab1.zip
cpython-cf117b0b4060a532e13980100c6f94ee98ec2ab1.tar.gz
cpython-cf117b0b4060a532e13980100c6f94ee98ec2ab1.tar.bz2
Rename 'proto' keyword arg to 'protocol' . Greg Ward's suggestion.
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r--Lib/pickle.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 84c5fe4..8431c41 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -167,11 +167,11 @@ del x
class Pickler:
- def __init__(self, file, proto=None, bin=None):
+ def __init__(self, file, protocol=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 protocol 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 protocol is not None and bin is not None:
+ raise ValueError, "can't specify both 'protocol' 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):
+ protocol = bin
+ if protocol is None:
+ protocol = 0
+ if protocol < 0:
+ protocol = 2
+ elif protocol 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(protocol)
+ self.bin = protocol >= 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, protocol=None, bin=None):
+ Pickler(file, protocol, bin).dump(obj)
-def dumps(obj, proto=None, bin=None):
+def dumps(obj, protocol=None, bin=None):
file = StringIO()
- Pickler(file, proto, bin).dump(obj)
+ Pickler(file, protocol, bin).dump(obj)
return file.getvalue()
def load(file):