diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-04-15 13:22:51 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-04-15 13:22:51 -0400 |
commit | 0b79941f37f6bd9a56afac0178713d082a0db0fb (patch) | |
tree | a4091e9455505d09a132732cbeed5d2a377190e0 /coverage | |
parent | dbf28ca29e5e372e5beec8b1d5b4abe5620d556d (diff) | |
download | python-coveragepy-0b79941f37f6bd9a56afac0178713d082a0db0fb.tar.gz |
If a module was loaded from a .pyc, report its file as .py
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/codeunit.py | 3 | ||||
-rw-r--r-- | coverage/control.py | 3 |
2 files changed, 3 insertions, 3 deletions
diff --git a/coverage/codeunit.py b/coverage/codeunit.py index 221d677..96ed43b 100644 --- a/coverage/codeunit.py +++ b/coverage/codeunit.py @@ -57,6 +57,9 @@ class CodeUnit: f = morf.__file__ else: f = morf + # .pyc files should always refer to a .py instead. + if f.endswith('.pyc'): + f = f[:-1] self.filename = file_locator.canonical_filename(f) if hasattr(morf, '__name__'): diff --git a/coverage/control.py b/coverage/control.py index db9b0a6..cb13f2f 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -119,9 +119,6 @@ class coverage: filename = code_unit.filename ext = os.path.splitext(filename)[1] source = None - if ext == '.pyc': - filename = filename[:-1] - ext = '.py' if ext == '.py': if not os.path.exists(filename): source = self.file_locator.get_zip_data(filename) |