Skip to content

Commit 0509c45

Browse files
authored
bpo-40521: Fix update_slot() when INTERN_NAME_STRINGS is not defined (#20246)
Fix type update_slot() function when the macro INTERN_NAME_STRINGS is not defined: use _PyUnicode_EQ() in this case.
1 parent aca4670 commit 0509c45

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Objects/typeobject.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7661,8 +7661,17 @@ update_slot(PyTypeObject *type, PyObject *name)
76617661
assert(slotdefs_initialized);
76627662
pp = ptrs;
76637663
for (p = slotdefs; p->name; p++) {
7664-
if (p->name_strobj == name)
7664+
assert(PyUnicode_CheckExact(p->name_strobj));
7665+
assert(PyUnicode_CheckExact(name));
7666+
#ifdef INTERN_NAME_STRINGS
7667+
if (p->name_strobj == name) {
7668+
*pp++ = p;
7669+
}
7670+
#else
7671+
if (p->name_strobj == name || _PyUnicode_EQ(p->name_strobj, name)) {
76657672
*pp++ = p;
7673+
}
7674+
#endif
76667675
}
76677676
*pp = NULL;
76687677
for (pp = ptrs; *pp; pp++) {

0 commit comments

Comments
 (0)