From 336d44593486288742e4b8009282da1af62d87ba Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Sun, 24 Dec 2023 11:01:53 +0100 Subject: [3.11] gh-113028: Correctly memoize str in pickle when escapes added (GH-113436) (GH-113449) 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. (cherry picked from commit 08398631a0298dcf785ee7bd0e26c7844823ce59) Co-authored-by: Jeff Allen --- Lib/pickle.py | 14 +++++++------- Lib/test/pickletester.py | 8 ++++++++ .../Library/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 f027e04..1160356 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -861,13 +861,13 @@ class _Pickler: else: self.write(BINUNICODE + pack("