diff --git a/src/build/toolset.py b/src/build/toolset.py index d7b121a2a..84fa767f0 100644 --- a/src/build/toolset.py +++ b/src/build/toolset.py @@ -117,8 +117,8 @@ def flags(rule_or_module, variable_name, condition, values = []): is specified, then the value of 'feature' will be added. """ - caller = bjam.caller()[:-1] - if not '.' in rule_or_module and caller.startswith("Jamfile"): + caller = bjam.caller() + if not '.' in rule_or_module and caller and caller[:-1].startswith("Jamfile"): # Unqualified rule name, used inside Jamfile. Most likely used with # 'make' or 'notfile' rules. This prevents setting flags on the entire # Jamfile module (this will be considered as rule), but who cares? diff --git a/src/engine/builtins.c b/src/engine/builtins.c index dc723e19b..449823973 100644 --- a/src/engine/builtins.c +++ b/src/engine/builtins.c @@ -2140,9 +2140,9 @@ PyObject * bjam_backtrace( PyObject * self, PyObject * args ) PyObject * bjam_caller( PyObject * self, PyObject * args ) { - PyObject *result = PyString_FromString( - frame_before_python_call->prev->module->name); - return result; + if ( !frame_before_python_call ) + Py_RETURN_NONE; + return PyString_FromString(frame_before_python_call->prev->module->name); } #endif /* #ifdef HAVE_PYTHON */ diff --git a/src/engine/compile.c b/src/engine/compile.c index 04783f1c8..dd8c7f22d 100644 --- a/src/engine/compile.c +++ b/src/engine/compile.c @@ -865,6 +865,7 @@ call_python_function(RULE* r, FRAME* frame) frame_before_python_call = frame; py_result = PyObject_Call( r->python_function, arguments, kw ); + frame_before_python_call = NULL; Py_DECREF(arguments); Py_XDECREF(kw); if ( py_result != NULL )