You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The final 'arg' argument of the sys.settrace() callback is documented to
be None for the 'c_return' and 'c_exception' events, but it appears to
be the function object itself. Additionally, the 'return' event's
argument may be None if the 'return' event is being generated because of
an exception. These errors also exist in the Py_tracefunc documentation
in the C API. The latter error is not particularly important for the
Python API, but in the C API the argument may be a NULL pointer.
I am happy to make the corrections if someone will confirm that my
analysis is correct.
It certainly seems to be implemented this way in ceval.c. I don't know
if the docs describe the implementation intent better, but I'd say that
this is then such a minor issue that just documenting the actual
behavior is the best thing to do.
The documentation of C_RETURN and C_EXCEPTION indeed says None while the function object is passed. This is seen in the implementation of the C_TRACE macro in Python/ceval.c
The arg of RETURN can be indeed NULL when caused by an exception. This is seen in the PyEval_EvalFrameEx function of Python/ceval.c right after the 'fast_yield' label.
The C/API documentation of Py_tracefunc shares the same errors with sys.settrace
As Georg said, the docs should be fixed to reflect the correct behavior.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: