[Python-Dev] sys.settrace does not produce events for C functions (original) (raw)

Pablo Galindo Salgado pablogsal at gmail.com
Sun Jan 21 14:40:05 EST 2018


The docs for sys.settrace mention that:

event is a string: 'call', 'line', 'return', 'exception', >> 'ccall', 'c_return', or 'c_exception'

But in the code for ceval.c the only point where call_trace is invoked with PyTrace_C_CALL or PyTrace_C_RETURN is under the C_TRACE macro. In this macro this line prevents any function set up using sys.settrace to call call_trace with the mentioned arguments:

if (tstate->use_tracing && tstate->c_profilefunc)

Notice that from the code of PyEval_SetTrace and PyEval_SetProfile, only the later sets tstate->c_profilefunc and therefore only functions installed using sys.setprofile will recieve a c_call for the event.

Xiang Zhan has suggested me to ask here what is the best course of action:

  1. Document this behavior.

  2. Fix the code.

This question is related to this issue: https://bugs.python.org/issue17799

Thanks everyone for your time!

Pablo -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180121/dab9b5ad/attachment.html>



More information about the Python-Dev mailing list