File: branch_trace.py

package info (click to toggle)
python-coverage 6.5.0%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,580 kB
  • sloc: python: 25,471; ansic: 1,152; javascript: 1,104; makefile: 253; sh: 107; xml: 48
file content (17 lines) | stat: -rw-r--r-- 291 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import sys

pairs = set()
last = -1

def trace(frame, event, arg):
    global last
    if event == "line":
        this = frame.f_lineno
        pairs.add((last, this))
        last = this
    return trace

code = open(sys.argv[1]).read()
sys.settrace(trace)
exec(code)
print(sorted(pairs))