summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2010-10-13 09:42:23 -0400
committerNed Batchelder <ned@nedbatchelder.com>2010-10-13 09:42:23 -0400
commit3f4d00fc8d55c92e4799cb3d26d75b169db9a414 (patch)
tree6dd4eda4ebddbcdcbe3f518d3bafa79d39b14d62
parentd46dfd5404a568ead3b14adcd6cfb4b81f51df1f (diff)
downloadpython-coveragepy-3f4d00fc8d55c92e4799cb3d26d75b169db9a414.tar.gz
Jython reports $py.class files in the trace function, so adapt to find the source file.
-rw-r--r--CHANGES.txt3
-rw-r--r--coverage/control.py5
2 files changed, 7 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index fe71f1f..a2a596d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -6,7 +6,8 @@ Change history for Coverage.py
Version 3.5
-----------
-
+- A little bit of Jython support: `coverage run` can now measure Jython
+ execution by adapting when $py.class files are traced.
Version 3.4 --- 19 September 2010
diff --git a/coverage/control.py b/coverage/control.py
index 28c8850..cdaf972 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -231,6 +231,11 @@ class coverage(object):
dunder_file = frame.f_globals.get('__file__')
if dunder_file:
filename = self._source_for_file(dunder_file)
+
+ # Jython reports the .class file to the tracer, use the source file.
+ if filename.endswith("$py.class"):
+ filename = filename[:-9] + ".py"
+
canonical = self.file_locator.canonical_filename(filename)
# If the user specified source, then that's authoritative about what to