Skip to content

Improved the output in case of exec syntax errors

Ghost User requested to merge (removed):do_exec-syntax-error-improvement into master
  • do_exec() now outputs file name, line number and offending code line

Given the following trivial RepoSurgeon extension script exec.py:

# Following line attempts to use print as statement
print "Test"

we would get the following error output prior to this patch:

reposurgeon% exec <./exec.py
reposurgeon: invalid syntax in extension function

after this patch it becomes a little more understandable:

reposurgeon% exec <./exec.py
reposurgeon: extension function - invalid syntax (exec.py, line 2)
print "Test"

although it is not immediately clear what the cause might be - it's due to reposurgeon using from __future__ import print_function - it is now clear which line is the culprit.

In a more complex script this can be very beneficial.

Merge request reports