summaryrefslogtreecommitdiff
path: root/coverage/pytracer.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-03-02 07:05:27 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-03-02 07:05:27 -0500
commit292becfc6657b0346b190a6489397e7fb6407cd3 (patch)
tree274c57bcab791c84cf185d59bc680ee902143e8f /coverage/pytracer.py
parent6d92b24be8a111f141dac958d821ebac75193781 (diff)
downloadpython-coveragepy-git-292becfc6657b0346b190a6489397e7fb6407cd3.tar.gz
Entry arcs now use the negative first line of the code object instead of -1.
Diffstat (limited to 'coverage/pytracer.py')
-rw-r--r--coverage/pytracer.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/coverage/pytracer.py b/coverage/pytracer.py
index cdb3ae70..47432324 100644
--- a/coverage/pytracer.py
+++ b/coverage/pytracer.py
@@ -92,9 +92,12 @@ class PyTracer(object):
self.cur_file_dict = self.data[tracename]
# The call event is really a "start frame" event, and happens for
# function calls and re-entering generators. The f_lasti field is
- # -1 for calls, and a real offset for generators. Use -1 as the
+ # -1 for calls, and a real offset for generators. Use <0 as the
# line number for calls, and the real line number for generators.
- self.last_line = -1 if (frame.f_lasti < 0) else frame.f_lineno
+ if frame.f_lasti < 0:
+ self.last_line = -frame.f_code.co_firstlineno
+ else:
+ self.last_line = frame.f_lineno
elif event == 'line':
# Record an executed line.
if self.cur_file_dict is not None: