]> granicus.if.org Git - python/commitdiff
Patch #750595: Refer to type complex using builtin. Fixes #595837.
authorMartin v. Löwis <martin@v.loewis.de>
Sat, 7 Jun 2003 20:10:54 +0000 (20:10 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sat, 7 Jun 2003 20:10:54 +0000 (20:10 +0000)
Backported to 2.2.

Lib/copy_reg.py

index 2ebafc736b7a27fba25bb6d53a726e629011f587..0477bcb541bd99109c20b8f2a6da9b770b75ad86 100644 (file)
@@ -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