From a48803b7a10e7f6b84d005da2e8ed0e2fcc549a9 Mon Sep 17 00:00:00 2001 From: Carl Friedrich Bolz-Tereick Date: Wed, 21 Apr 2021 20:14:37 +0200 Subject: [PATCH 1/2] bpo-43907: add missing memoize call in pure python pickling of bytearray in protocol 5 --- Lib/pickle.py | 1 + Lib/test/pickletester.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Lib/pickle.py b/Lib/pickle.py index e63a8b6e4dbb70..5ab312f2acaee6 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -818,6 +818,7 @@ def save_bytearray(self, obj): self._write_large_bytes(BYTEARRAY8 + pack(" Date: Fri, 23 Apr 2021 20:57:25 +0200 Subject: [PATCH 2/2] add news entry --- .../next/Library/2021-04-23-20-57-20.bpo-43907.3RJEjv.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2021-04-23-20-57-20.bpo-43907.3RJEjv.rst diff --git a/Misc/NEWS.d/next/Library/2021-04-23-20-57-20.bpo-43907.3RJEjv.rst b/Misc/NEWS.d/next/Library/2021-04-23-20-57-20.bpo-43907.3RJEjv.rst new file mode 100644 index 00000000000000..7da3a1c3f76127 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-04-23-20-57-20.bpo-43907.3RJEjv.rst @@ -0,0 +1,4 @@ +Fix a bug in the pure-Python pickle implementation when using protocol 5, +where bytearray instances that occur several time in the pickled object +graph would incorrectly unpickle into repeated copies of the bytearray +object.