zopefoundation/z3c.coverage — pull request #1 by ulif (2013-09-26 11:37:46+00:00)
Title: Coveragereport crashes with non-ASCII chars in sources

z3c.coverage was updated to cope with Python 3.3 and pypy. Thanks a lot for this!

Unfortunately, because of the different strings/bytes handling in Python 3.3 the changes had to make assumptions about the encoding of enscript output (or any other syntax highlighter). It simply assumed that this output would be plain ASCII which might not be true for all sources. At least UTF-8 and friends should be accepted in source files.

As a result current z3c.coverage crashes with UnicodeEncodeError if any UTF-8 chars appear somewhere in parsed Python sources.

My patch now assumes the output of enscript to be latin-1 encoded, which is the enscript default (according to man page). With this changed setting, UTF-8 encoded source files might lead to scrumbled HTML output (as enscript does not detect input encodings, only output encoding is settable) but this was true in former versions of z3c.coverage already. And the whole thing stops crashing with usual UTF-8 chars :-)

I am not sure whether there is a better way to deal with this, though.