summaryrefslogtreecommitdiff
path: root/test/farm/run/src/showtrace.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-04-27 09:42:41 -0400
committerNed Batchelder <ned@nedbatchelder.com>2011-04-27 09:42:41 -0400
commita243a6a2b34eb9ef5cba3346796160e06ba77930 (patch)
treee9c0f8a9dab30b5f15ebaa408a90ed523b4a9f18 /test/farm/run/src/showtrace.py
parentc826639c8ba8e9076ace7d030dc5a9f6f899c9ee (diff)
downloadpython-coveragepy-git-a243a6a2b34eb9ef5cba3346796160e06ba77930.tar.gz
C trace function now roundtrips properly. Fixes #123 and #125.
--HG-- branch : bug_123
Diffstat (limited to 'test/farm/run/src/showtrace.py')
-rw-r--r--test/farm/run/src/showtrace.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/farm/run/src/showtrace.py b/test/farm/run/src/showtrace.py
index c3b4356c..e97412e0 100644
--- a/test/farm/run/src/showtrace.py
+++ b/test/farm/run/src/showtrace.py
@@ -4,7 +4,7 @@
import sys
# Show what the trace function is. If a C-based function is used, then f_trace
-# is None.
+# may be None.
trace_fn = sys._getframe(0).f_trace
if trace_fn is None:
trace_name = "None"
@@ -13,6 +13,11 @@ else:
try:
trace_name = trace_fn.im_class.__name__
except AttributeError:
- trace_name = trace_fn.__self__.__class__.__name__
+ try:
+ trace_name = trace_fn.__self__.__class__.__name__
+ except AttributeError:
+ # A C-based function could also manifest as an f_trace value
+ # which doesn't have im_class or __self__.
+ trace_name = trace_fn.__class__.__name__
print("%s %s" % (sys.argv[1], trace_name))