Skip to content

*.pyo file handling in CodeUnit #195

@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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions