2011-01-23

PSF core grant, day 12

Today was focused on diagnosing various issues related to running Python's test suite under coverage. I fixed a test in test_sys which triggered a fatal error under coverage.py. While doing that I discovered that a bunch of tests are changing what trace function is running, which is a no-no. This also led to discovering that a bunch of tests simply fail under coverage (a cursory look suggests that refcount tests are the culprit).

And this doesn't cover the specific issues of the two ways of generating coverage. For the trace module, the biggest issue is that it throws an exception if it can't find a file it traced. This is annoying for temporary files that created, imported, and then deleted; test_importlib and test_runpy does this along with others.

For coverage.py, I discovered that it is not opening source files based on the declared encoding. While typically this is not an issue, there are some files in the stdlib (e.g., Lib/sqlite/test/dbapi.py) which are encoded in Latin-1 and contain code points which are outside the valid range for UTF-8. Luckily Python 3.2 introduced tokenize.open() which allowed me to easily write a patch for the problem.