Issue1751
Created on 2011-05-30.18:52:20 by geoffbache, last changed 2017-06-23.16:53:54 by zyasoft.
msg6532 (view) |
Author: Geoff Bache (geoffbache) |
Date: 2011-05-30.18:52:19 |
|
I've been trying to measure coverage of my Jython program and finding
that (at least) all lines containing "try:", "except:" or "break"
never get shown as covered.
This appears to be because the sys.settrace function, on which
coverage.py relies for its information, is not triggered by such
lines.
For example, compare the output of the following program under Jython
and CPython. No output is created for lines 10, 12 or 13 when running
under Jython, whereas it is for CPython.
import sys
def tracefunc(frame, event, arg):
print "Trace", event, frame.f_lineno
return tracefunc
def do():
x = [ 1 ]
for i in range(2):
try:
x[i]
except IndexError:
break
sys.settrace(tracefunc)
do()
|
msg11020 (view) |
Author: Ned Batchelder (nedbat) |
Date: 2017-01-14.19:27:54 |
|
BTW, #1248 is a dup of this issue.
|
msg11025 (view) |
Author: Ned Batchelder (nedbat) |
Date: 2017-01-19.00:26:56 |
|
"with" statements are also overlooked:
import linecache, sys
def tracefunc(frame, event, arg):
lineno = frame.f_lineno
print "Trace", event, lineno, linecache.getline(__file__, lineno).rstrip()
return tracefunc
def do():
x = [ 1 ]
for i in range(2):
try:
x[i]
except IndexError:
break
with open(__file__) as f:
print len(f.read())
sys.settrace(tracefunc)
do()
Produces:
Trace call 8 def do():
Trace line 9 x = [ 1 ]
Trace line 10 for i in range(2):
Trace line 10 for i in range(2):
Trace line 12 x[i]
Trace line 10 for i in range(2):
Trace line 12 x[i]
Trace exception 12 x[i]
Trace line 17 print len(f.read())
397
Trace return 17 print len(f.read())
|
msg11444 (view) |
Author: Jim Baker (zyasoft) |
Date: 2017-06-23.16:53:54 |
|
Let's track with #1248 (try/except) and #2540 (with)
|
|
Date |
User |
Action |
Args |
2017-06-23 16:53:54 | zyasoft | set | status: open -> closed resolution: remind -> duplicate messages:
+ msg11444 |
2017-01-19 00:26:56 | nedbat | set | messages:
+ msg11025 |
2017-01-14 19:27:54 | nedbat | set | messages:
+ msg11020 |
2017-01-14 19:26:45 | nedbat | set | nosy:
+ nedbat |
2015-11-02 03:17:56 | zyasoft | set | milestone: Jython 2.7.2 |
2014-07-01 04:09:32 | zyasoft | set | nosy:
+ zyasoft |
2013-02-20 00:10:19 | fwierzbicki | set | nosy:
+ fwierzbicki |
2013-02-20 00:10:12 | fwierzbicki | set | priority: normal resolution: remind versions:
+ Jython 2.5, - 2.5.2rc |
2011-05-30 18:52:20 | geoffbache | create | |
|