From: Martin v. Löwis Date: Sat, 7 Jun 2003 20:10:54 +0000 (+0000) Subject: Patch #750595: Refer to type complex using builtin. Fixes #595837. X-Git-Tag: v2.3c1~524 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=502ba4630358423dc3da4da0f3f938d3cb56281f;p=python Patch #750595: Refer to type complex using builtin. Fixes #595837. Backported to 2.2. --- diff --git a/Lib/copy_reg.py b/Lib/copy_reg.py index 2ebafc736b..0477bcb541 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