Skip to content
Next Next commit
Make _try_compile print shorter traceback
This commit reworks code of '_try_compile' function so that it print shorter traceback if its 'source' argument contains indentation/syntax error
  • Loading branch information
chgnrdv committed Feb 21, 2023
commit 271917994138714ec76251194ecbfff49383a611
2 changes: 2 additions & 0 deletions Lib/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def _try_compile(source, name):
try:
c = compile(source, name, 'eval')
except SyntaxError:
c = None
if not c:
Comment thread
iritkatriel marked this conversation as resolved.
Outdated
Comment thread
iritkatriel marked this conversation as resolved.
Outdated
c = compile(source, name, 'exec')
return c

Expand Down