diff --git a/src/pl/plpython/plpy_elog.c b/src/pl/plpython/plpy_elog.c index 7d3d0d4981..7495e7d51d 100644 --- a/src/pl/plpython/plpy_elog.c +++ b/src/pl/plpython/plpy_elog.c @@ -255,6 +255,12 @@ PLy_traceback(PyObject *e, PyObject *v, PyObject *tb, PG_TRY(); { + /* + * Ancient versions of Python (circa 2.3) contain a bug whereby + * the fetches below can fail if the error indicator is set. + */ + PyErr_Clear(); + lineno = PyObject_GetAttrString(tb, "tb_lineno"); if (lineno == NULL) elog(ERROR, "could not get line number from Python traceback");