Skip to content

Commit

Permalink
Improve error when input is not valid Python
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-sans-paille committed Oct 17, 2024
1 parent 4c93690 commit b61a770
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pythran/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@ def run():
logger.critical("Cover me Jack. Jack? Jaaaaack!!!!\n"
"E: " + str(e))
sys.exit(1)
except SyntaxError as se:
# pythran syntax error formatter is just nicer
pse = PythranSyntaxError(se.args[0])
pse.filename, pse.lineno, pse.offset = se.args[1][:3]
if pse.filename == '<unknown>':
pse.filename = args.input_file
pse.offset -= 1

logger.critical("I think in all humility that your input code is not valid Python, "
"that's a bit too much for me :-/\n" + str(pse))
sys.exit(1)
except NotImplementedError:
logger.critical("MAYDAY, MAYDAY, MAYDAY; pythran compiler; "
"code area out of control\n"
Expand Down

0 comments on commit b61a770

Please sign in to comment.