summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-02-03 16:59:48 (GMT)
committerGuido van Rossum <guido@python.org>2003-02-03 16:59:48 (GMT)
commit795ea89cb51edbebcb23149db5bf95fcb55857b9 (patch)
tree2979558812b33aa7d7f6e0f1579d6d86019946e3 /Lib
parent31f119ebdb0c82a6d06fc94a2d6ad9eedd0a2bec (diff)
downloadcpython-795ea89cb51edbebcb23149db5bf95fcb55857b9.zip
cpython-795ea89cb51edbebcb23149db5bf95fcb55857b9.tar.gz
cpython-795ea89cb51edbebcb23149db5bf95fcb55857b9.tar.bz2
Support keyword argument 'bin', with a pending deprecation warning.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/pickle.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 926869e..0d553a7 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -167,7 +167,7 @@ del x
class Pickler:
- def __init__(self, file, proto=0):
+ def __init__(self, file, proto=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
@@ -191,6 +191,14 @@ 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 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):
@@ -1464,12 +1472,12 @@ try:
except ImportError:
from StringIO import StringIO
-def dump(obj, file, proto=0):
- Pickler(file, proto).dump(obj)
+def dump(obj, file, proto=None, bin=None):
+ Pickler(file, proto, bin).dump(obj)
-def dumps(obj, proto=0):
+def dumps(obj, proto=None, bin=None):
file = StringIO()
- Pickler(file, proto).dump(obj)
+ Pickler(file, proto, bin).dump(obj)
return file.getvalue()
def load(file):