summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/copy_reg.py14
-rw-r--r--Lib/io.py6
2 files changed, 15 insertions, 5 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
diff --git a/Lib/io.py b/Lib/io.py
index b2860f4..fd39826 100644
--- a/Lib/io.py
+++ b/Lib/io.py
@@ -30,10 +30,14 @@ __all__ = ["BlockingIOError", "open", "IOBase", "RawIOBase", "FileIO",
import os
import sys
import codecs
-import pickle
import _fileio
import warnings
+try:
+ import cPickle as pickle
+except ImportError:
+ import pickle
+
# XXX Shouldn't we use st_blksize whenever we can?
DEFAULT_BUFFER_SIZE = 8 * 1024 # bytes