python coverage fails with ‘invalid syntax’ – solution

July 22, 2009 – 21:43

If you get

class 'coverage.CoverageException'>: Couldn't parse '<filename>' 
as Python source: 'invalid syntax' at line 1

just make sure that your file has correct line endings. I’ve spent some time guessing until converted dos line ends to unix ones. :)

  • http://nedbatchelder.com Ned Batchelder

    What version of coverage.py is this with? I thought I had fixed all those issues in the 3.0 release…

  • Andrey Khavryuchenko

    @Ned:

    Yes, this is coverage-2.78-py2.5.egg – the latest available via easy_install coverage

    Updated via easy_install coverage==3.0.1, thanks.