diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-10-24 18:14:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-24 18:14:23 (GMT) |
commit | 8cd1dbae32d9303caac3a473d3332f17bc98c921 (patch) | |
tree | 883e8288636eb076d168d2ea57b7a406e2a9d429 /Lib/copyreg.py | |
parent | 473db47747bb8bc986d88ad81799bcbd88153ac5 (diff) | |
download | cpython-8cd1dbae32d9303caac3a473d3332f17bc98c921.zip cpython-8cd1dbae32d9303caac3a473d3332f17bc98c921.tar.gz cpython-8cd1dbae32d9303caac3a473d3332f17bc98c921.tar.bz2 |
bpo-41052: Fix pickling heap types implemented in C with protocols 0 and 1 (GH-22870)
Diffstat (limited to 'Lib/copyreg.py')
-rw-r--r-- | Lib/copyreg.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/copyreg.py b/Lib/copyreg.py index dfc463c..7ab8c12 100644 --- a/Lib/copyreg.py +++ b/Lib/copyreg.py @@ -48,6 +48,7 @@ def _reconstructor(cls, base, state): return obj _HEAPTYPE = 1<<9 +_new_type = type(int.__new__) # Python code for object.__reduce_ex__ for protocols 0 and 1 @@ -57,6 +58,9 @@ def _reduce_ex(self, proto): for base in cls.__mro__: if hasattr(base, '__flags__') and not base.__flags__ & _HEAPTYPE: break + new = base.__new__ + if isinstance(new, _new_type) and new.__self__ is base: + break else: base = object # not really reachable if base is object: |