forked from bartvdbraak/blender
bug fix: sigsegv when script had syntax errors
This commit is contained in:
parent
9edf1c08a6
commit
609f5b7f9c
@ -175,7 +175,7 @@ void BPY_Err_Handle(Text *text)
|
|||||||
PyErr_Restore(exception, err, tb); // takes away reference!
|
PyErr_Restore(exception, err, tb); // takes away reference!
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
tb = PySys_GetObject("last_traceback");
|
tb = PySys_GetObject("last_traceback");
|
||||||
Py_INCREF(tb);
|
Py_XINCREF(tb);
|
||||||
|
|
||||||
/* From old bpython BPY_main.c:
|
/* From old bpython BPY_main.c:
|
||||||
* 'check traceback objects and look for last traceback in the
|
* 'check traceback objects and look for last traceback in the
|
||||||
@ -183,15 +183,17 @@ void BPY_Err_Handle(Text *text)
|
|||||||
* error occured. "If the error occured in another text file or module,
|
* error occured. "If the error occured in another text file or module,
|
||||||
* the last frame in the current file is adressed."' */
|
* the last frame in the current file is adressed."' */
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
v = PyObject_GetAttrString(tb, "tb_next");
|
v = PyObject_GetAttrString(tb, "tb_next");
|
||||||
|
|
||||||
if (v == Py_None ||
|
if (v == Py_None || strcmp(PyString_AsString(traceback_getFilename(v)),
|
||||||
strcmp(PyString_AsString(traceback_getFilename(v)), GetName(text)))
|
GetName(text))) {
|
||||||
break;
|
break;
|
||||||
Py_DECREF(tb);
|
}
|
||||||
tb = v;
|
|
||||||
}
|
Py_DECREF(tb);
|
||||||
|
tb = v;
|
||||||
|
}
|
||||||
|
|
||||||
v = PyObject_GetAttrString(tb, "tb_lineno");
|
v = PyObject_GetAttrString(tb, "tb_lineno");
|
||||||
g_script_error.lineno = PyInt_AsLong(v);
|
g_script_error.lineno = PyInt_AsLong(v);
|
||||||
@ -482,8 +484,6 @@ PyObject * RunPython(Text *text, PyObject *globaldict)
|
|||||||
|
|
||||||
if (PyErr_Occurred()) {
|
if (PyErr_Occurred()) {
|
||||||
BPY_free_compiled_text(text);
|
BPY_free_compiled_text(text);
|
||||||
PyErr_SetString (PyExc_RuntimeError,
|
|
||||||
"couldn't compile script to Python bytecode");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user