From 08398631a0298dcf785ee7bd0e26c7844823ce59 Mon Sep 17 00:00:00 2001 From: Jeff Allen Date: Sun, 24 Dec 2023 09:43:44 +0000 Subject: [PATCH] gh-113028: Correctly memoize str in pickle when escapes added (GH-113436) This fixes a divergence between the Python and C implementations of pickle for protocol 0, such that it pickle.py fails to re-use the first pickled representation of strings involving characters that have to be escaped. --- Lib/pickle.py | 14 +++++++------- Lib/test/pickletester.py | 8 ++++++++ .../2023-12-23-16-51-17.gh-issue-113028.3Jmdoj.rst | 6 ++++++ 3 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2023-12-23-16-51-17.gh-issue-113028.3Jmdoj.rst diff --git a/Lib/pickle.py b/Lib/pickle.py index 4f5ad5b71e8899..988c0887341310 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -857,13 +857,13 @@ def save_str(self, obj): else: self.write(BINUNICODE + pack("