Handling Exceptions¶
Errors happen, and when they do, in traditional make fashion, the make functions
described in Makefile Functions as well as any make functions created by
using export()
simply return an empty string. Assuming that
at some point you would like to know what when wrong, Py-gnumake provides some
basic debugging facilities.
Getting the last error¶
Any time an uncaught exception occurs, the make variable .PYTHON_LAST_ERROR
is set with the exception type and text. For example, it might contain the
string SyntaxError: invalid syntax
. This variable is unset any time Python
code is run without an uncaught exception.
Showing the full traceback¶
If the make variable .PYTHON_PRINT_TRACEBACK
is set to some non-empty
value, the Python stack trace will be printed to stderr anytime that an
uncaught exception occurs. This is very useful for debugging, and it is
convenient to set this variable via the command line.
Using the Python debugger¶
The Python debugger works just fine from within Py-gnumake. You can break into arbitrary Python code by inserting the following line:
import pdb; pdb.set_trace()