summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2023-02-08 22:07:03 -0700
committerNed Batchelder <ned@nedbatchelder.com>2023-02-08 22:07:03 -0700
commitd10e5e25248b7e89701fe4cb3d9032244fb31c8f (patch)
tree74b30600ca6b0bf7645d7e308aa1a96a0dea437b
parent8f3e7b45b3aabf4d7d01dc470010d3d36f30a0ba (diff)
downloadpython-coveragepy-git-nedbat/debug-1554.tar.gz
temp: more debugging for #1554nedbat/debug-1554
-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':