Skip to content

Commit c3fd600

Browse files
author
rocky
committed
Improve error message when not giving a pyc or pyo.
1 parent b7143f9 commit c3fd600

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

xdis/bin/pydisasm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def main(format: list[str], method: tuple, show_source: bool, files):
9292

9393
try:
9494
disassemble_file(path, sys.stdout, format, show_source=show_source, methods=method)
95-
except ImportError as e:
95+
except (ImportError, NotImplementedError, ValueError) as e:
9696
print(e)
9797
rc = 3
9898
sys.exit(rc)

xdis/disasm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def disassemble_file(
341341
source_size,
342342
sip_hash,
343343
) = load_module(pyc_filename)
344-
except (ImportError, NotImplementedError):
344+
except (ImportError, NotImplementedError, ValueError):
345345
raise
346346
except Exception:
347347
# Hack alert: we're using pyc_filename set as a proxy for whether the filename exists.

xdis/load.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def check_object_path(path: str) -> str:
101101

102102
if not is_bytecode_extension(path):
103103
raise ValueError(
104-
f"path {path} must point to a Python source that can be compiled, or Python bytecode (.pyc, .pyo)\n"
104+
f"Path {path} must point to a Python source that can be compiled, or Python bytecode (.pyc, .pyo)\n"
105105
)
106106
return path
107107

0 commit comments

Comments
 (0)