summaryrefslogtreecommitdiff
path: root/lab
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-07-13 07:34:46 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-07-13 07:34:46 -0400
commitcaf7639d9a74d8adda15ad08fa1201c47efba86b (patch)
tree782d7dc4a57677956633d94fb2ae16854349938c /lab
parent448cf97f998b99d5555099f24f53f81bfda7a523 (diff)
downloadpython-coveragepy-git-caf7639d9a74d8adda15ad08fa1201c47efba86b.tar.gz
test: the code I use for bpo reports
Diffstat (limited to 'lab')
-rw-r--r--lab/bpo_prelude.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/lab/bpo_prelude.py b/lab/bpo_prelude.py
new file mode 100644
index 00000000..cc86a84d
--- /dev/null
+++ b/lab/bpo_prelude.py
@@ -0,0 +1,12 @@
+import linecache, sys
+
+def trace(frame, event, arg):
+ # The weird globals here is to avoid a NameError on shutdown...
+ if frame.f_code.co_filename == globals().get("__file__"):
+ lineno = frame.f_lineno
+ print("{} {}: {}".format(event[:4], lineno, linecache.getline(__file__, lineno).rstrip()))
+ return trace
+
+print(sys.version)
+sys.settrace(trace)
+