Skip to content

Commit 78186af

Browse files
committed
Better detection when decompiler isn't available
1 parent 10a7027 commit 78186af

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

trepan/__main__.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ def main(dbg=None, sys_argv=list(sys.argv)):
144144
raise IOError(
145145
f"Python file name embedded in code {try_file} not found"
146146
)
147+
except ImportError as e:
148+
print(str(e))
149+
sys.exit(3)
147150
except IOError:
148151
decompiler = "uncompyle6"
149152
try:
@@ -154,12 +157,17 @@ def main(dbg=None, sys_argv=list(sys.argv)):
154157

155158
decompiler = "decompyle3"
156159
except ImportError:
157-
print(
158-
"%s: Compiled python file '%s', but %s not found"
159-
% (__title__, mainpyfile, decompiler),
160-
file=sys.stderr,
161-
)
162-
sys.exit(1)
160+
if PYTHON_VERSION_TRIPLE >= (3, 9):
161+
print(
162+
"%s: Decompiler not available for %s." % (__title__, version_tuple_to_str()),
163+
file=sys.stderr,
164+
)
165+
else:
166+
print(
167+
"%s: Compiled python file '%s', but %s not found"
168+
% (__title__, mainpyfile, decompiler),
169+
file=sys.stderr,
170+
)
163171

164172
short_name = osp.basename(mainpyfile).strip(".pyc")
165173
fd = tempfile.NamedTemporaryFile(

0 commit comments

Comments
 (0)