summaryrefslogtreecommitdiff
path: root/coverage/python.py
diff options
context:
space:
mode:
Diffstat (limited to 'coverage/python.py')
-rw-r--r--coverage/python.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/coverage/python.py b/coverage/python.py
index 98b0d6ab..b57fccf3 100644
--- a/coverage/python.py
+++ b/coverage/python.py
@@ -64,7 +64,12 @@ def get_python_source(filename: str) -> str:
# Replace \f because of http://bugs.python.org/issue19035
source_bytes = source_bytes.replace(b'\f', b' ')
- source = source_bytes.decode(source_encoding(source_bytes), "replace")
+ try:
+ source = source_bytes.decode(source_encoding(source_bytes), "replace")
+ except:
+ print(f"Failed on {filename!r}")
+ print(f"Source bytes ({len(source_bytes)} total): {source_bytes[:80]!r}")
+ raise
# Python code should always end with a line with a newline.
if source and source[-1] != '\n':