From 269cb342ad487c7c244659bd25ed6d4d7bb95876 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:08 +0100 Subject: [3.12] gh-113028: Correctly memoize str in pickle when escapes added (GH-113436) (GH-113448) 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 fe86f80..f54a607 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -855,13 +855,13 @@ class _Pickler: else: self.write(BINUNICODE + pack("