Skip to content

Commit 2bb306d

Browse files
committed
Avoid non-exported dict helpers in _asyncio
1 parent 084827a commit 2bb306d

1 file changed

Lines changed: 7 additions & 19 deletions

File tree

Modules/_asynciomodule.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -403,30 +403,18 @@ loop_has_instance_call_soon_shadow(PyObject *loop)
403403
// Respect instance-level monkeypatching such as:
404404
// loop.call_soon = custom_call_soon
405405
// These must keep using the public slow path.
406-
PyTypeObject *loop_type = Py_TYPE(loop);
407406
PyObject *attr = NULL;
408-
409-
if ((loop_type->tp_flags & Py_TPFLAGS_INLINE_VALUES) &&
410-
_PyObject_TryGetInstanceAttribute(loop, &_Py_ID(call_soon), &attr)) {
411-
int has_shadow = attr != NULL;
412-
Py_XDECREF(attr);
413-
return has_shadow;
414-
}
415-
416-
PyObject *dict;
417-
if (loop_type->tp_flags & Py_TPFLAGS_MANAGED_DICT) {
418-
dict = (PyObject *)_PyObject_GetManagedDict(loop);
419-
}
420-
else {
421-
PyObject **dictptr = _PyObject_ComputedDictPointer(loop);
422-
dict = dictptr != NULL ? FT_ATOMIC_LOAD_PTR_ACQUIRE(*dictptr) : NULL;
423-
}
424-
407+
PyObject *dict = PyObject_GenericGetDict(loop, NULL);
425408
if (dict == NULL) {
426-
return 0;
409+
if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
410+
PyErr_Clear();
411+
return 0;
412+
}
413+
return -1;
427414
}
428415

429416
int rc = PyDict_GetItemRef(dict, &_Py_ID(call_soon), &attr);
417+
Py_DECREF(dict);
430418
if (rc < 0) {
431419
return -1;
432420
}

0 commit comments

Comments
 (0)