Alex Rivera | Logout

Python's sys.settrace won't create c_call events

Asked 2013-04-19T23:51:33.413
8

The documentation for sys.settrace says that it can report calls to c or builtin functions. When I try following program, I expect to see a c_call event, but nothing happens:

import sys

def tracer(frame, event, arg):
    print(frame, event, arg)
    return tracer

sys.settrace(tracer)

x = len([1,2,3])

Any ideas what's wrong here?

Can anyone post an example use of sys.settrace which generates a c_call event?

EDIT: Initially I tried it with Python 3.2, and it gave me no events. Now I tried it with Python 2.7 and it gave me two call-s (not c_call-s). Still weird.

Edit
Report

1 Answer

7

The docs are wrong, c_call events will never be sent to your trace function: http://bugs.python.org/issue17799

answered 2013-04-20T11:27:35.140

Your Answer