Skip to content

C API functions should never be called when the error indicator is set #2

@iritkatriel

Description

@iritkatriel

There are functions that may not be called with an error set, for example:

    /* PyObject_Repr() must not be called with an exception set,
       because it can clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!_PyErr_Occurred(tstate));

But this is not asserted for most of the C API functions.

In Python, it is not possible to execute code when there is an in-flight exception so C API should not allow that either and it should be checked for all API functions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions