(original) (raw)
The docs for sys.settrace mention that:
>> event is a string: 'call', 'line', 'return', 'exception', >> 'c\_call', '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:
Thanks everyone for your time!
Pablo