@@ -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
@@ -4027,7 +4022,7 @@ type_setattro(PyTypeObject *type, PyObject *name, PyObject *value)
4027
4022
if (name == NULL )
4028
4023
return -1 ;
4029
4024
}
4030
- #ifdef INTERN_NAME_STRINGS
4025
+ /* bpo-40521: Interned strings are shared by all subinterpreters */
4031
4026
if (!PyUnicode_CHECK_INTERNED (name )) {
4032
4027
PyUnicode_InternInPlace (& name );
4033
4028
if (!PyUnicode_CHECK_INTERNED (name )) {
@@ -4037,7 +4032,6 @@ type_setattro(PyTypeObject *type, PyObject *name, PyObject *value)
4037
4032
return -1 ;
4038
4033
}
4039
4034
}
4040
- #endif
4041
4035
}
4042
4036
else {
4043
4037
/* Will fail in _PyObject_GenericSetAttrWithDict. */
@@ -8474,17 +8468,11 @@ _PyTypes_InitSlotDefs(void)
8474
8468
for (slotdef * p = slotdefs ; p -> name ; p ++ ) {
8475
8469
/* Slots must be ordered by their offset in the PyHeapTypeObject. */
8476
8470
assert (!p [1 ].name || p -> offset <= p [1 ].offset );
8477
- #ifdef INTERN_NAME_STRINGS
8471
+ /* bpo-40521: Interned strings are shared by all subinterpreters */
8478
8472
p -> name_strobj = PyUnicode_InternFromString (p -> name );
8479
8473
if (!p -> name_strobj || !PyUnicode_CHECK_INTERNED (p -> name_strobj )) {
8480
8474
return _PyStatus_NO_MEMORY ();
8481
8475
}
8482
- #else
8483
- p -> name_strobj = PyUnicode_FromString (p -> name );
8484
- if (!p -> name_strobj ) {
8485
- return _PyStatus_NO_MEMORY ();
8486
- }
8487
- #endif
8488
8476
}
8489
8477
slotdefs_initialized = 1 ;
8490
8478
return _PyStatus_OK ();
@@ -8509,24 +8497,17 @@ update_slot(PyTypeObject *type, PyObject *name)
8509
8497
int offset ;
8510
8498
8511
8499
assert (PyUnicode_CheckExact (name ));
8512
- #ifdef INTERN_NAME_STRINGS
8513
8500
assert (PyUnicode_CHECK_INTERNED (name ));
8514
- #endif
8515
8501
8516
8502
assert (slotdefs_initialized );
8517
8503
pp = ptrs ;
8518
8504
for (p = slotdefs ; p -> name ; p ++ ) {
8519
8505
assert (PyUnicode_CheckExact (p -> name_strobj ));
8520
8506
assert (PyUnicode_CheckExact (name ));
8521
- #ifdef INTERN_NAME_STRINGS
8507
+ /* bpo-40521: Using interned strings. */
8522
8508
if (p -> name_strobj == name ) {
8523
8509
* pp ++ = p ;
8524
8510
}
8525
- #else
8526
- if (p -> name_strobj == name || _PyUnicode_EQ (p -> name_strobj , name )) {
8527
- * pp ++ = p ;
8528
- }
8529
- #endif
8530
8511
}
8531
8512
* pp = NULL ;
8532
8513
for (pp = ptrs ; * pp ; pp ++ ) {
0 commit comments