]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40521: Fix update_slot() when INTERN_NAME_STRINGS is not defined (#20246)
authorVictor Stinner <vstinner@python.org>
Tue, 19 May 2020 23:57:17 +0000 (01:57 +0200)
committerGitHub <noreply@github.com>
Tue, 19 May 2020 23:57:17 +0000 (01:57 +0200)
Fix type update_slot() function when the macro INTERN_NAME_STRINGS is
not defined: use _PyUnicode_EQ() in this case.

Objects/typeobject.c

index 243f8811b6257109b6af962f9a0ce8b7809c6977..0e055d677f139ef40e56beac42548758d4c961c9 100644 (file)
@@ -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++) {