Skip to content

Py_EnterRecursiveCall()/_Py_EnterRecursiveCall() return value misused in a number of places #101965

Closed
@OTheDev

Description

@OTheDev

Using grep, I identified 3 instances in main where code checks if Py_EnterRecursiveCall(...) < 0 (which just returns _Py_EnterRecursiveCall(...)) or _Py_EnterRecursiveCall(...) < 0.

  1. Py_EnterRecursiveCall() documentation only guarantees that a nonzero value is returned in the event of an error.
  2. The actual implementation can't return a negative value:

static inline int _Py_EnterRecursiveCallTstate(PyThreadState *tstate,
const char *where) {
return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where));
}
static inline int _Py_EnterRecursiveCall(const char *where) {
PyThreadState *tstate = _PyThreadState_GET();
return _Py_EnterRecursiveCallTstate(tstate, where);
}

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions