try / except / finally causes parser to fail

Issue #105 invalid
ebmeierj created an issue

It appears that there is a problem with the new try / except / finally statement which is supported by python as of version 2.5.

Example: {{{

!python

import sys from coverage import coverage coverage(data_file='coverage.dat', auto_data=True).start()

def main(): try: print "hello world"

except:
    print "exception"

finally:
    print "world contacted"

if name == "main": main() }}}

Then if you run {{{

!python

import sys from coverage import *

cov = coverage(data_file='coverage.dat') cov.load() cov.report() }}}

You will see the following exception: CoverageException: Couldn't parse '/interact/test/test.py' as Python source: 'invalid syntax' at line 14

(The line that the error happens on is the finally following the except.)

Comments (2)

  1. Ned Batchelder repo owner

    Are you sure you're running the coverage script under 2.5? This error would happen if you were running the second script under 2.4.

  2. Log in to comment