bug fix: sigsegv when script had syntax errors

This commit is contained in:
2003-05-23 04:37:33 +00:00
parent 9edf1c08a6
commit 609f5b7f9c

View File

@@ -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
@@ -186,9 +186,11 @@ void BPY_Err_Handle(Text *text)
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); Py_DECREF(tb);
tb = v; tb = 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;
} }