Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 552
Aivar Avatar asked Apr 19 '13 23:04

Aivar


1 Answers

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

like image 117
Concerned Citizen Avatar answered Oct 17 '22 02:10

Concerned Citizen