This commit is contained in:
abebus 2025-12-23 01:13:34 +03:00
parent 9cec5f2720
commit 4d9f06885c
2 changed files with 6 additions and 6 deletions

View file

@ -1259,12 +1259,15 @@ class CodeConstsTest(unittest.TestCase):
with self.subTest(global_string=global_string):
self.assertIsInterned(eval(f"'{global_string}'"))
noninternable_by_default = textwrap.dedent('''
noninternable_by_default = textwrap.dedent(f'''
not-internable
not.internable
не_интернируемый
str with spaces
''' + '\U00100000')
{chr(0x011111)}
{chr(0x9999)}
{chr(0x100)}
''')
@cpython_only
@unittest.skipIf(Py_GIL_DISABLED, "free-threaded build interns all string constants")

View file

@ -205,9 +205,6 @@ static int
intern_constants(PyObject *tuple, int *modified)
{
PyInterpreterState *interp = _PyInterpreterState_GET();
#if !defined(Py_GIL_DISABLED)
PyObject *interned_dict = get_interned_dict(interp);
#endif
for (Py_ssize_t i = PyTuple_GET_SIZE(tuple); --i >= 0; ) {
PyObject *v = PyTuple_GET_ITEM(tuple, i);
if (PyUnicode_CheckExact(v) && PyUnicode_GET_LENGTH(v) > 1) {
@ -217,7 +214,7 @@ intern_constants(PyObject *tuple, int *modified)
#if !defined(Py_GIL_DISABLED)
PyObject *interned = _Py_hashtable_get(INTERNED_STRINGS, v);
if (interned == NULL) {
interned = PyDict_GetItemWithError(interned_dict, v);
interned = PyDict_GetItemWithError(get_interned_dict(interp), v);
if (PyErr_Occurred()) return -1;
}
if (interned != NULL && interned != v) {