@@ -54,11 +54,6 @@ typedef struct PySlot_Offset {
54
54
} PySlot_Offset ;
55
55
56
56
57
- /* bpo-40521: Interned strings are shared by all subinterpreters */
58
- #ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
59
- # define INTERN_NAME_STRINGS
60
- #endif
61
-
62
57
static PyObject *
63
58
slot_tp_new (PyTypeObject * type , PyObject * args , PyObject * kwds );
64
59
@@ -4009,7 +4004,7 @@ type_setattro(PyTypeObject *type, PyObject *name, PyObject *value)
4009
4004
if (name == NULL )
4010
4005
return -1 ;
4011
4006
}
4012
- #ifdef INTERN_NAME_STRINGS
4007
+ /* bpo-40521: Interned strings are shared by all subinterpreters */
4013
4008
if (!PyUnicode_CHECK_INTERNED (name )) {
4014
4009
PyUnicode_InternInPlace (& name );
4015
4010
if (!PyUnicode_CHECK_INTERNED (name )) {
@@ -4019,7 +4014,6 @@ type_setattro(PyTypeObject *type, PyObject *name, PyObject *value)
4019
4014
return -1 ;
4020
4015
}
4021
4016
}
4022
- #endif
4023
4017
}
4024
4018
else {
4025
4019
/* Will fail in _PyObject_GenericSetAttrWithDict. */
@@ -8456,17 +8450,11 @@ _PyTypes_InitSlotDefs(void)
8456
8450
for (slotdef * p = slotdefs ; p -> name ; p ++ ) {
8457
8451
/* Slots must be ordered by their offset in the PyHeapTypeObject. */
8458
8452
assert (!p [1 ].name || p -> offset <= p [1 ].offset );
8459
- #ifdef INTERN_NAME_STRINGS
8453
+ /* bpo-40521: Interned strings are shared by all subinterpreters */
8460
8454
p -> name_strobj = PyUnicode_InternFromString (p -> name );
8461
8455
if (!p -> name_strobj || !PyUnicode_CHECK_INTERNED (p -> name_strobj )) {
8462
8456
return _PyStatus_NO_MEMORY ();
8463
8457
}
8464
- #else
8465
- p -> name_strobj = PyUnicode_FromString (p -> name );
8466
- if (!p -> name_strobj ) {
8467
- return _PyStatus_NO_MEMORY ();
8468
- }
8469
- #endif
8470
8458
}
8471
8459
slotdefs_initialized = 1 ;
8472
8460
return _PyStatus_OK ();
@@ -8491,24 +8479,17 @@ update_slot(PyTypeObject *type, PyObject *name)
8491
8479
int offset ;
8492
8480
8493
8481
assert (PyUnicode_CheckExact (name ));
8494
- #ifdef INTERN_NAME_STRINGS
8495
8482
assert (PyUnicode_CHECK_INTERNED (name ));
8496
- #endif
8497
8483
8498
8484
assert (slotdefs_initialized );
8499
8485
pp = ptrs ;
8500
8486
for (p = slotdefs ; p -> name ; p ++ ) {
8501
8487
assert (PyUnicode_CheckExact (p -> name_strobj ));
8502
8488
assert (PyUnicode_CheckExact (name ));
8503
- #ifdef INTERN_NAME_STRINGS
8489
+ /* bpo-40521: Using interned strings. */
8504
8490
if (p -> name_strobj == name ) {
8505
8491
* pp ++ = p ;
8506
8492
}
8507
- #else
8508
- if (p -> name_strobj == name || _PyUnicode_EQ (p -> name_strobj , name )) {
8509
- * pp ++ = p ;
8510
- }
8511
- #endif
8512
8493
}
8513
8494
* pp = NULL ;
8514
8495
for (pp = ptrs ; * pp ; pp ++ ) {
0 commit comments