classification
Title: Argument for sys.settrace() callbacks documented incorrectly
Type: behavior Stage:
Components: Documentation Versions: Python 3.2, Python 3.1, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: eli.bendersky, georg.brandl, robert.kern, terry.reedy
Priority: normal Keywords:

Created on 2009-08-28 23:52 by robert.kern, last changed 2010-10-15 16:42 by georg.brandl. This issue is now closed.

Messages (5)
msg92050 - (view) Author: Robert Kern (robert.kern) Date: 2009-08-28 23:52
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.
msg92125 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-09-01 07:51
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.
msg112700 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-03 21:54
Eli, any comment on this?
msg112745 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2010-08-04 03:36
I can confirm Robert's findings. 

1) 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

2) 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.

3) 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.
msg118799 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-10-15 16:42
Should be fixed in r85540.
History
Date User Action Args
2010-10-15 16:42:47georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg118799
2010-08-04 03:36:14eli.benderskysetmessages: + msg112745
2010-08-03 21:54:29terry.reedysetnosy: + terry.reedy, eli.bendersky

messages: + msg112700
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6, Python 2.5
2009-09-01 07:51:29georg.brandlsetmessages: + msg92125
2009-08-28 23:52:04robert.kerncreate