Skip to content

Commit

Permalink
Trace isfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Singh committed Jun 21, 2024
1 parent e2c5519 commit d9ce55f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/libcalc/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
import os
import sys

def profilefunc(frame, event, arg):
if event == 'call':
if frame.f_code.co_name == 'isfile' and frame.f_back.f_code.co_name == 'find_library':
for i in range(frame.f_code.co_argcount):
name = frame.f_code.co_varnames[i]
print(frame.f_locals[name])

sys.setprofile(profilefunc)
import libcalc
sys.setprofile(None)

def die(msg):
print(msg)
Expand Down

0 comments on commit d9ce55f

Please sign in to comment.