summaryrefslogtreecommitdiffstats
path: root/Lib/copy_reg.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-04-11 05:40:58 (GMT)
committerGuido van Rossum <guido@python.org>2007-04-11 05:40:58 (GMT)
commit0dd32e246cd232012d07926ae312205decb74b61 (patch)
treebaf67ba755cabaf97a021dd4823087303e7ee5e3 /Lib/copy_reg.py
parent0ad0812edb3b4023f3e410243c007fba3f84a9ff (diff)
downloadcpython-0dd32e246cd232012d07926ae312205decb74b61.zip
cpython-0dd32e246cd232012d07926ae312205decb74b61.tar.gz
cpython-0dd32e246cd232012d07926ae312205decb74b61.tar.bz2
Real pickling for bytes.
Restore complex pickling. Use cPickle in io.py.
Diffstat (limited to 'Lib/copy_reg.py')
-rw-r--r--Lib/copy_reg.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/copy_reg.py b/Lib/copy_reg.py
index 8760e62..f4661ed 100644
--- a/Lib/copy_reg.py
+++ b/Lib/copy_reg.py
@@ -23,12 +23,18 @@ def constructor(object):
if not callable(object):
raise TypeError("constructors must be callable")
-# Example: provide pickling support for bytes objects.
+# Example: provide pickling support for complex numbers.
-def _pickle_bytes(b):
- return bytes, (str(b),)
+try:
+ complex
+except NameError:
+ pass
+else:
-pickle(bytes, _pickle_bytes)
+ def pickle_complex(c):
+ return complex, (c.real, c.imag)
+
+ pickle(complex, pickle_complex, complex)
# Support for pickling new-style objects