summaryrefslogtreecommitdiffstats
path: root/Lib/copy_reg.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/copy_reg.py')
-rw-r--r--Lib/copy_reg.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/copy_reg.py b/Lib/copy_reg.py
index 2ebafc7..0477bcb 100644
--- a/Lib/copy_reg.py
+++ b/Lib/copy_reg.py
@@ -28,10 +28,16 @@ def constructor(object):
# Example: provide pickling support for complex numbers.
-def pickle_complex(c):
- return complex, (c.real, c.imag)
+try:
+ complex
+except NameError:
+ pass
+else:
-pickle(type(1j), pickle_complex, complex)
+ def pickle_complex(c):
+ return complex, (c.real, c.imag)
+
+ pickle(complex, pickle_complex, complex)
# Support for pickling new-style objects