diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-06-11 22:02:32 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-06-11 22:02:32 -0400 |
commit | be5178fda38750c0aae78061bf1b1bf3397a467d (patch) | |
tree | 9fecc8d7481259fd7267b208d018edb1b22daa6f /coverage/html.py | |
parent | 8f5aa5738644bf81c2d0547de5bbe5f77548b1a9 (diff) | |
download | python-coveragepy-git-be5178fda38750c0aae78061bf1b1bf3397a467d.tar.gz |
Prevent UnicodeDecodeErrors in html report. #303
Diffstat (limited to 'coverage/html.py')
-rw-r--r-- | coverage/html.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/coverage/html.py b/coverage/html.py index 6c811107..85f47ab4 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -238,15 +238,9 @@ class HtmlReporter(Reporter): })) if sys.version_info < (3, 0): - try: - html = html.decode(encoding) - except UnicodeDecodeError as e: - sample = e.object[max([0, e.start-30]):e.start+30] - raise CoverageException( - "Couldn't decode %r as %s: %r" % ( - cu.filename, e.encoding, sample - ) - ) + # In theory, all the characters in the source can be decoded, but + # strange things happen, so use 'replace' to keep errors at bay. + html = html.decode(encoding, 'replace') html_filename = flat_rootname + ".html" html_path = os.path.join(self.directory, html_filename) |