diff options
author | Guido van Rossum <guido@python.org> | 2003-02-13 16:30:16 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-02-13 16:30:16 (GMT) |
commit | 298e4214538a7196c27ec22b1f01506fdb3c4039 (patch) | |
tree | 6d75d061df43965e30b132c378802c5488fd8f64 /Lib/copy_reg.py | |
parent | 0c016a9590b3da47f19420d0616e0c72cae19abf (diff) | |
download | cpython-298e4214538a7196c27ec22b1f01506fdb3c4039.zip cpython-298e4214538a7196c27ec22b1f01506fdb3c4039.tar.gz cpython-298e4214538a7196c27ec22b1f01506fdb3c4039.tar.bz2 |
SF patch #685738 by Michael Stone.
This changes the default __new__ to refuse arguments iff tp_init is the
default __init__ implementation -- thus making it a TypeError when you
try to pass arguments to a constructor if the class doesn't override at
least __init__ or __new__.
Diffstat (limited to 'Lib/copy_reg.py')
-rw-r--r-- | Lib/copy_reg.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/copy_reg.py b/Lib/copy_reg.py index 11ae960..6dc52c2 100644 --- a/Lib/copy_reg.py +++ b/Lib/copy_reg.py @@ -33,11 +33,14 @@ def pickle_complex(c): pickle(type(1j), pickle_complex, complex) -# Support for picking new-style objects +# Support for pickling new-style objects def _reconstructor(cls, base, state): - obj = base.__new__(cls, state) - base.__init__(obj, state) + if base is object: + obj = object.__new__(cls) + else: + obj = base.__new__(cls, state) + base.__init__(obj, state) return obj _HEAPTYPE = 1<<9 |