summaryrefslogtreecommitdiffstats
path: root/Objects/methodobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-11-05 00:22:12 (GMT)
committerGitHub <noreply@github.com>2019-11-05 00:22:12 (GMT)
commit17269090940aa20f6079a6b9f27ae319f8cdae14 (patch)
treef2c785c3fb8efb972639df7179b6d5b3b315e888 /Objects/methodobject.c
parentbe434dc0380d9f5c7c800de9943cc46d55fd9491 (diff)
downloadcpython-17269090940aa20f6079a6b9f27ae319f8cdae14.zip
cpython-17269090940aa20f6079a6b9f27ae319f8cdae14.tar.gz
cpython-17269090940aa20f6079a6b9f27ae319f8cdae14.tar.bz2
bpo-38644: Pass tstate to _Py_CheckFunctionResult() (GH-17050)
* Add tstate parameter to _Py_CheckFunctionResult() * Add _PyErr_FormatFromCauseTstate() * Replace PyErr_XXX(...) with _PyErr_XXX(state, ...)
Diffstat (limited to 'Objects/methodobject.c')
-rw-r--r--Objects/methodobject.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 3ce1560..c780904 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -454,9 +454,11 @@ cfunction_vectorcall_O(
static PyObject *
cfunction_call(PyObject *func, PyObject *args, PyObject *kwargs)
{
- assert(!PyErr_Occurred());
assert(kwargs == NULL || PyDict_Check(kwargs));
+ PyThreadState *tstate = _PyThreadState_GET();
+ assert(!_PyErr_Occurred(tstate));
+
int flags = PyCFunction_GET_FLAGS(func);
if (!(flags & METH_VARARGS)) {
/* If this is not a METH_VARARGS function, delegate to vectorcall */
@@ -474,11 +476,12 @@ cfunction_call(PyObject *func, PyObject *args, PyObject *kwargs)
}
else {
if (kwargs != NULL && PyDict_GET_SIZE(kwargs) != 0) {
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- ((PyCFunctionObject*)func)->m_ml->ml_name);
+ _PyErr_Format(tstate, PyExc_TypeError,
+ "%.200s() takes no keyword arguments",
+ ((PyCFunctionObject*)func)->m_ml->ml_name);
return NULL;
}
result = meth(self, args);
}
- return _Py_CheckFunctionResult(func, result, NULL);
+ return _Py_CheckFunctionResult(tstate, func, result, NULL);
}