PyObject * cb;
PyObject * data;
rpmtsObject * tso;
- int pythonError;
PyThreadState *_save;
};
return Py_None;
}
+static void die(PyObject *cb)
+{
+ char *pyfn = NULL;
+ PyObject *r;
+
+ if (PyErr_Occurred()) {
+ PyErr_Print();
+ }
+ if ((r = PyObject_Repr(cb)) != NULL) {
+ pyfn = PyString_AsString(r);
+ }
+ fprintf(stderr, _("error: python callback %s failed, aborting!\n"),
+ pyfn ? pyfn : "???");
+ rpmdbCheckTerminate(1);
+ exit(EXIT_FAILURE);
+}
+
/** \ingroup py_c
*/
static PyObject *
fprintf(stderr, "*** rpmts_SolveCallback(%p,%p,%p) \"%s\"\n", ts, ds, data, rpmdsDNEVR(ds));
if (cbInfo->tso == NULL) return res;
- if (cbInfo->pythonError) return res;
if (cbInfo->cb == Py_None) return res;
PyEval_RestoreThread(cbInfo->_save);
Py_DECREF(args);
if (!result) {
- cbInfo->pythonError = 1;
+ die(cbInfo->cb);
} else {
if (PyInt_Check(result))
res = PyInt_AsLong(result);
fprintf(stderr, "*** rpmts_Check(%p) ts %p cb %p\n", s, s->ts, cbInfo.cb);
cbInfo.tso = s;
- cbInfo.pythonError = 0;
cbInfo._save = PyEval_SaveThread();
xx = rpmtsCheck(s->ts);
PyObject * args, * result;
static FD_t fd;
- if (cbInfo->pythonError) return NULL;
if (cbInfo->cb == Py_None) return NULL;
/* Synthesize a python object for callback (if necessary). */
Py_DECREF(pkgObj);
if (!result) {
- cbInfo->pythonError = 1;
- cbInfo->_save = PyEval_SaveThread();
- return NULL;
+ die(cbInfo->cb);
}
if (what == RPMCALLBACK_INST_OPEN_FILE) {
int fdno;
if (!PyArg_Parse(result, "i", &fdno)) {
- cbInfo->pythonError = 1;
- cbInfo->_save = PyEval_SaveThread();
- return NULL;
+ die(cbInfo->cb);
}
Py_DECREF(result);
cbInfo->_save = PyEval_SaveThread();
return NULL;
cbInfo.tso = s;
- cbInfo.pythonError = 0;
cbInfo._save = PyEval_SaveThread();
if (cbInfo.cb != NULL) {
PyEval_RestoreThread(cbInfo._save);
- if (cbInfo.pythonError) {
- ps = rpmpsFree(ps);
- return NULL;
- }
-
if (rc < 0) {
list = PyList_New(0);
return list;