[Python-checkins] bpo-40521: Fix update_slot() when INTERN_NAME_STRINGS is not defined (#20246)

Victor Stinner webhook-mailer at python.org
Tue May 19 19:57:23 EDT 2020


https://github.com/python/cpython/commit/0509c4547fc95cc32a91ac446a26192c3bfdf157
commit: 0509c4547fc95cc32a91ac446a26192c3bfdf157
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-05-20T01:57:17+02:00
summary:

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.

files:
M Objects/typeobject.c

diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 243f8811b6257..0e055d677f139 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++) {



More information about the Python-checkins mailing list