Skip to content

Commit 09f829b

Browse files
authored
use PyType_GetSlot() when using the fallback
1 parent 3b5f12b commit 09f829b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Objects/typeobject.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5297,12 +5297,11 @@ get_base_by_token_recursive(PyTypeObject *type, void *token)
52975297
Py_ssize_t n = PyTuple_GET_SIZE(bases);
52985298
for (Py_ssize_t i = 0; i < n; i++) {
52995299
PyTypeObject *base = _PyType_CAST(PyTuple_GET_ITEM(bases, i));
5300-
if (!_PyType_HasFeature(base, Py_TPFLAGS_HEAPTYPE)) {
5301-
continue;
5302-
}
5303-
if (((PyHeapTypeObject*)base)->ht_token == token) {
5300+
// The MRO version can slow down if this takes the same approach
5301+
if (PyType_GetSlot(base, Py_tp_token) == token) {
53045302
return base;
53055303
}
5304+
assert(!PyErr_Occurred());
53065305
base = get_base_by_token_recursive(base, token);
53075306
if (base != NULL) {
53085307
return base;

0 commit comments

Comments
 (0)