bpo-38787: Add PyCFunction_CheckExact() macro for exact type checks (GH-20024)

… now that we allow subtypes of PyCFunction.

Also add PyCMethod_CheckExact() and PyCMethod_Check() for checks against the PyCMethod subtype.
This commit is contained in:
scoder 2020-05-12 16:12:41 +02:00 committed by GitHub
parent 5650e76f63
commit 4c9ea093cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 4 deletions

View file

@ -5054,7 +5054,7 @@ trace_call_function(PyThreadState *tstate,
PyObject *kwnames)
{
PyObject *x;
if (PyCFunction_Check(func)) {
if (PyCFunction_CheckExact(func) || PyCMethod_CheckExact(func)) {
C_TRACE(x, PyObject_Vectorcall(func, args, nargs, kwnames));
return x;
}
@ -5115,7 +5115,7 @@ do_call_core(PyThreadState *tstate, PyObject *func, PyObject *callargs, PyObject
{
PyObject *result;
if (PyCFunction_Check(func)) {
if (PyCFunction_CheckExact(func) || PyCMethod_CheckExact(func)) {
C_TRACE(result, PyObject_Call(func, callargs, kwdict));
return result;
}