[issue39947] [C API] Make the PyThreadState structure opaque (move it to the internal C API)

STINNER Victor report at bugs.python.org
Mon Jun 1 22:04:06 EDT 2020


STINNER Victor <vstinner at python.org> added the comment:

Cython still access multiple PyThreadState members which have no getter or setter yet.

__Pyx_PyErr_ExceptionMatchesInState():

    PyObject *exc_type = tstate->curexc_type;
    ...

=> internal _PyErr_Occurred(tstate) could solve this issue: move it the public/private API? Or expose internal _PyErr_ExceptionMatches(tstate, exc)?

__Pyx_ErrRestoreInState() is a reimplementation of internal _PyErr_Restore(): get/set curexc_type, curexc_value and curexc_traceback members.

__Pyx_PyFunction_FastCallNoKw:

static PyObject* __Pyx_PyFunction_FastCallNoKw(...) {
    ...
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}

Why not calling Py_EnterRecursiveCall/Py_LeaveRecursiveCall?

There are likely others.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39947>
_______________________________________


More information about the Python-bugs-list mailing list