]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40521: Fix PyUnicode_InternInPlace() (GH-22376)
authorVictor Stinner <vstinner@python.org>
Wed, 23 Sep 2020 12:05:32 +0000 (14:05 +0200)
committerGitHub <noreply@github.com>
Wed, 23 Sep 2020 12:05:32 +0000 (14:05 +0200)
Fix PyUnicode_InternInPlace() when the INTERNED_STRINGS macro is not
defined (when the EXPERIMENTAL_ISOLATED_SUBINTERPRETERS macro is
defined).

Objects/unicodeobject.c

index fd0e8e008adae4cf41885b105143cd56967f21d2..f32ab417c364caf4a91fce6c9e37edf7628a91a4 100644 (file)
@@ -15754,6 +15754,10 @@ PyUnicode_InternInPlace(PyObject **p)
        this. */
     Py_SET_REFCNT(s, Py_REFCNT(s) - 2);
     _PyUnicode_STATE(s).interned = SSTATE_INTERNED_MORTAL;
+#else
+    // PyDict expects that interned strings have their hash
+    // (PyASCIIObject.hash) already computed.
+    (void)unicode_hash(s);
 #endif
 }