mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
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, ...)
This commit is contained in:
parent
be434dc038
commit
1726909094
7 changed files with 94 additions and 52 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue