https://github.com/python/cpython/commit/7c328b6e84a5adfdb5719c9c63ef4e4333858f71
commit: 7c328b6e84a5adfdb5719c9c63ef4e4333858f71
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-10-10T13:35:48+03:00
summary:

[3.15] gh-157892: Fix error check on _Py_hashtable_set() in intern_static() 
(GH-157898) (GH-158301)

_Py_hashtable_set() returns -1 on failure, so the "< -1" check could never be 
true and the Py_FatalError() call was unreachable.
(cherry picked from commit a4eb936727e5f949f5dc8c8a38bf6d325518f29b)

Co-authored-by: Rishi Raj <[email protected]>

files:
M Objects/unicodeobject.c

diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index ad24bc5d83933a..b0b5e01a0f4e9a 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -14181,7 +14181,7 @@ intern_static(PyInterpreterState *interp, PyObject *s 
/* stolen */)
         return Py_NewRef(r);
     }
 
-    if (_Py_hashtable_set(INTERNED_STRINGS, s, s) < -1) {
+    if (_Py_hashtable_set(INTERNED_STRINGS, s, s) < 0) {
         Py_FatalError("failed to intern static string");
     }
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to