diff options
author | Victor Stinner <vstinner@python.org> | 2019-11-05 00:22:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-05 00:22:12 (GMT) |
commit | 17269090940aa20f6079a6b9f27ae319f8cdae14 (patch) | |
tree | f2c785c3fb8efb972639df7179b6d5b3b315e888 /Include | |
parent | be434dc0380d9f5c7c800de9943cc46d55fd9491 (diff) | |
download | cpython-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 'Include')
-rw-r--r-- | Include/cpython/abstract.h | 12 | ||||
-rw-r--r-- | Include/internal/pycore_pyerrors.h | 6 |
2 files changed, 14 insertions, 4 deletions
diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index 04e4a9e..be37e19 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -37,9 +37,11 @@ PyAPI_FUNC(PyObject *) _PyStack_AsDict( 40 bytes on the stack. */ #define _PY_FASTCALL_SMALL_STACK 5 -PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *callable, - PyObject *result, - const char *where); +PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult( + PyThreadState *tstate, + PyObject *callable, + PyObject *result, + const char *where); /* === Vectorcall protocol (PEP 590) ============================= */ @@ -98,13 +100,15 @@ _PyObject_Vectorcall(PyObject *callable, PyObject *const *args, { assert(kwnames == NULL || PyTuple_Check(kwnames)); assert(args != NULL || PyVectorcall_NARGS(nargsf) == 0); + + PyThreadState *tstate = PyThreadState_GET(); vectorcallfunc func = _PyVectorcall_Function(callable); if (func == NULL) { Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); return _PyObject_MakeTpCall(callable, args, nargs, kwnames); } PyObject *res = func(callable, args, nargsf, kwnames); - return _Py_CheckFunctionResult(callable, res, NULL); + return _Py_CheckFunctionResult(tstate, callable, res, NULL); } /* Same as _PyObject_Vectorcall except that keyword arguments are passed as diff --git a/Include/internal/pycore_pyerrors.h b/Include/internal/pycore_pyerrors.h index 2efbf4a..edbfdfa 100644 --- a/Include/internal/pycore_pyerrors.h +++ b/Include/internal/pycore_pyerrors.h @@ -58,6 +58,12 @@ PyAPI_FUNC(void) _PyErr_NormalizeException( PyObject **val, PyObject **tb); +PyAPI_FUNC(PyObject *) _PyErr_FormatFromCauseTstate( + PyThreadState *tstate, + PyObject *exception, + const char *format, + ...); + #ifdef __cplusplus } #endif |