*.pyo file handling in CodeUnit · Issue #195 · nedbat/coveragepy (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@nedbat

Description

@nedbat

Originally reported by Marius Gedminas (Bitbucket: mgedmin, GitHub: mgedmin)


I was reading the source code and this bit in CodeUnit.init caught my eye. Shouldn't it handle *.pyo in addition to *.pyc?

#!diff
diff -r [b65fad3cee1d (bb)](https://bitbucket.org/ned/coveragepy/commits/b65fad3cee1d) coverage/codeunit.py
--- a/coverage/codeunit.py      Sun Sep 02 15:00:20 2012 -0400
+++ b/coverage/codeunit.py      Thu Sep 06 13:53:56 2012 +0300
@@ -52,7 +52,7 @@
         else:
             f = morf
         # .pyc files should always refer to a .py instead.
-        if f.endswith('.pyc'):
+        if f.endswith('.pyc') or f.endswith('.pyo'):
             f = f[:-1]
         self.filename = self.file_locator.canonical_filename(f)