From d10e5e25248b7e89701fe4cb3d9032244fb31c8f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 8 Feb 2023 22:07:03 -0700 Subject: temp: more debugging for #1554 --- coverage/python.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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': -- cgit v1.2.1