diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-05-06 10:43:52 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-05-06 10:43:52 -0400 |
commit | f29cd6fbb45d4916bc5ef46ec0113a4763618544 (patch) | |
tree | eb993a0d5381c0b1ee014aa2d7140f4307e1c1a2 /coverage | |
parent | 9a49b797a3832cb34d8aa490c62277821524c9ec (diff) | |
download | python-coveragepy-git-f29cd6fbb45d4916bc5ef46ec0113a4763618544.tar.gz |
Still noodling on how best to incorporate Detlev Offenbach's code finding patch.
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/control.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/coverage/control.py b/coverage/control.py index ab9112ef..3c6b55a0 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -40,25 +40,28 @@ class coverage: should not. """ + ofilename = filename if filename == '<string>': # There's no point in ever tracing string executions, we can't do # anything with the data later anyway. return False # Compiled Python files have two filenames: frame.f_code.co_filename is - # the filename where the .pyc was originally compiled. The second name + # the filename at the time the .pyc was compiled. The second name # is __file__, which is where the .pyc was actually loaded from. Since # .pyc files can be moved after compilation (for example, by being # installed), we look for __file__ in the frame and prefer it to the # co_filename value. dunder_file = frame.f_globals.get('__file__') if dunder_file: + if not dunder_file.endswith(".py"): + dunder_file = dunder_file[:-1] filename = dunder_file - if not filename.endswith(".py"): - filename = filename[:-1] canonical = self.file_locator.canonical_filename(filename) - + + #print "of: %r\nfn: %r\n__: %r\nca: %r\n" % (ofilename, filename, dunder_file, canonical) + # If we aren't supposed to trace the stdlib, then check if this is in # the stdlib and skip it if so. if not self.cover_stdlib: |