Skip to content

Commit 4d9f068

Browse files
why
1 parent 9cec5f2 commit 4d9f068

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Lib/test/test_code.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,12 +1259,15 @@ def test__Py_DECLARE_STR_is_interned(self):
12591259
with self.subTest(global_string=global_string):
12601260
self.assertIsInterned(eval(f"'{global_string}'"))
12611261

1262-
noninternable_by_default = textwrap.dedent('''
1262+
noninternable_by_default = textwrap.dedent(f'''
12631263
not-internable
12641264
not.internable
12651265
не_интернируемый
12661266
str with spaces
1267-
''' + '\U00100000')
1267+
{chr(0x011111)}
1268+
{chr(0x9999)}
1269+
{chr(0x100)}
1270+
''')
12681271

12691272
@cpython_only
12701273
@unittest.skipIf(Py_GIL_DISABLED, "free-threaded build interns all string constants")

Objects/codeobject.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,6 @@ static int
205205
intern_constants(PyObject *tuple, int *modified)
206206
{
207207
PyInterpreterState *interp = _PyInterpreterState_GET();
208-
#if !defined(Py_GIL_DISABLED)
209-
PyObject *interned_dict = get_interned_dict(interp);
210-
#endif
211208
for (Py_ssize_t i = PyTuple_GET_SIZE(tuple); --i >= 0; ) {
212209
PyObject *v = PyTuple_GET_ITEM(tuple, i);
213210
if (PyUnicode_CheckExact(v) && PyUnicode_GET_LENGTH(v) > 1) {
@@ -217,7 +214,7 @@ intern_constants(PyObject *tuple, int *modified)
217214
#if !defined(Py_GIL_DISABLED)
218215
PyObject *interned = _Py_hashtable_get(INTERNED_STRINGS, v);
219216
if (interned == NULL) {
220-
interned = PyDict_GetItemWithError(interned_dict, v);
217+
interned = PyDict_GetItemWithError(get_interned_dict(interp), v);
221218
if (PyErr_Occurred()) return -1;
222219
}
223220
if (interned != NULL && interned != v) {

0 commit comments

Comments
 (0)