summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-05-19 23:57:17 (GMT)
committerGitHub <noreply@github.com>2020-05-19 23:57:17 (GMT)
commit0509c4547fc95cc32a91ac446a26192c3bfdf157 (patch)
tree616fe6bd2c4160bd5d55f332ae6c24f852471825 /Objects
parentaca4670ad695d4b01c7880fe3d0af817421945bd (diff)
downloadcpython-0509c4547fc95cc32a91ac446a26192c3bfdf157.zip
cpython-0509c4547fc95cc32a91ac446a26192c3bfdf157.tar.gz
cpython-0509c4547fc95cc32a91ac446a26192c3bfdf157.tar.bz2
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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 243f881..0e055d6 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -7661,8 +7661,17 @@ update_slot(PyTypeObject *type, PyObject *name)
assert(slotdefs_initialized);
pp = ptrs;
for (p = slotdefs; p->name; p++) {
- if (p->name_strobj == name)
+ assert(PyUnicode_CheckExact(p->name_strobj));
+ assert(PyUnicode_CheckExact(name));
+#ifdef INTERN_NAME_STRINGS
+ if (p->name_strobj == name) {
+ *pp++ = p;
+ }
+#else
+ if (p->name_strobj == name || _PyUnicode_EQ(p->name_strobj, name)) {
*pp++ = p;
+ }
+#endif
}
*pp = NULL;
for (pp = ptrs; *pp; pp++) {