Message6532

Author geoffbache
Recipients geoffbache
Date 2011-05-30.18:52:19
SpamBayes Score 9.15117e-11
Marked as misclassified No
Message-id <1306781540.43.0.985500138857.issue1751@psf.upfronthosting.co.za>
In-reply-to
Content
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()
History
Date User Action Args
2011-05-30 18:52:20geoffbachesetrecipients: + geoffbache
2011-05-30 18:52:20geoffbachesetmessageid: <1306781540.43.0.985500138857.issue1751@psf.upfronthosting.co.za>
2011-05-30 18:52:20geoffbachelinkissue1751 messages
2011-05-30 18:52:19geoffbachecreate