@@ -54,11 +54,6 @@ typedef struct PySlot_Offset {
5454} PySlot_Offset ;
5555
5656
57- /* bpo-40521: Interned strings are shared by all subinterpreters */
58- #ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
59- # define INTERN_NAME_STRINGS
60- #endif
61-
6257static PyObject *
6358slot_tp_new (PyTypeObject * type , PyObject * args , PyObject * kwds );
6459
@@ -4027,7 +4022,7 @@ type_setattro(PyTypeObject *type, PyObject *name, PyObject *value)
40274022 if (name == NULL )
40284023 return -1 ;
40294024 }
4030- #ifdef INTERN_NAME_STRINGS
4025+ /* bpo-40521: Interned strings are shared by all subinterpreters */
40314026 if (!PyUnicode_CHECK_INTERNED (name )) {
40324027 PyUnicode_InternInPlace (& name );
40334028 if (!PyUnicode_CHECK_INTERNED (name )) {
@@ -4037,7 +4032,6 @@ type_setattro(PyTypeObject *type, PyObject *name, PyObject *value)
40374032 return -1 ;
40384033 }
40394034 }
4040- #endif
40414035 }
40424036 else {
40434037 /* Will fail in _PyObject_GenericSetAttrWithDict. */
@@ -8474,17 +8468,11 @@ _PyTypes_InitSlotDefs(void)
84748468 for (slotdef * p = slotdefs ; p -> name ; p ++ ) {
84758469 /* Slots must be ordered by their offset in the PyHeapTypeObject. */
84768470 assert (!p [1 ].name || p -> offset <= p [1 ].offset );
8477- #ifdef INTERN_NAME_STRINGS
8471+ /* bpo-40521: Interned strings are shared by all subinterpreters */
84788472 p -> name_strobj = PyUnicode_InternFromString (p -> name );
84798473 if (!p -> name_strobj || !PyUnicode_CHECK_INTERNED (p -> name_strobj )) {
84808474 return _PyStatus_NO_MEMORY ();
84818475 }
8482- #else
8483- p -> name_strobj = PyUnicode_FromString (p -> name );
8484- if (!p -> name_strobj ) {
8485- return _PyStatus_NO_MEMORY ();
8486- }
8487- #endif
84888476 }
84898477 slotdefs_initialized = 1 ;
84908478 return _PyStatus_OK ();
@@ -8509,24 +8497,17 @@ update_slot(PyTypeObject *type, PyObject *name)
85098497 int offset ;
85108498
85118499 assert (PyUnicode_CheckExact (name ));
8512- #ifdef INTERN_NAME_STRINGS
85138500 assert (PyUnicode_CHECK_INTERNED (name ));
8514- #endif
85158501
85168502 assert (slotdefs_initialized );
85178503 pp = ptrs ;
85188504 for (p = slotdefs ; p -> name ; p ++ ) {
85198505 assert (PyUnicode_CheckExact (p -> name_strobj ));
85208506 assert (PyUnicode_CheckExact (name ));
8521- #ifdef INTERN_NAME_STRINGS
8507+ /* bpo-40521: Using interned strings. */
85228508 if (p -> name_strobj == name ) {
85238509 * pp ++ = p ;
85248510 }
8525- #else
8526- if (p -> name_strobj == name || _PyUnicode_EQ (p -> name_strobj , name )) {
8527- * pp ++ = p ;
8528- }
8529- #endif
85308511 }
85318512 * pp = NULL ;
85328513 for (pp = ptrs ; * pp ; pp ++ ) {
0 commit comments