summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-04-11 18:17:02 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-04-11 18:17:02 -0400
commit112e5d2a8b32d574daba9fec9b34bdad01937f76 (patch)
treeb4a6a46e9d43b58ec3d324012beb4a5f3edeeb25
parentd54de3962a12e6075eae80fe75afc3ab59eea0d5 (diff)
Fix freshly-introduced PL/Python portability bug.
It turns out that those PyErr_Clear() calls I removed from plpy_elog.c in 7e3bb080387f4143 et al were not quite as random as they appeared: they mask a Python 2.3.x bug. (Specifically, it turns out that PyType_Ready() can fail if the error indicator is set on entry, and PLy_traceback's fetch of frame.f_code may be the first operation in a session that requires the "frame" type to be readied. Ick.) Put back the clear call, but in a more centralized place closer to what it's protecting, and this time with a comment warning what it's really for. Per buildfarm member prairiedog. Although prairiedog was only failing on HEAD, it seems clearly possible for this to occur in older branches as well, so back-patch to 9.2 the same as the previous patch.
-rw-r--r--src/pl/plpython/plpy_elog.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/pl/plpython/plpy_elog.c b/src/pl/plpython/plpy_elog.c
index 5a01d364255..1e2836ec50d 100644
--- a/src/pl/plpython/plpy_elog.c
+++ b/src/pl/plpython/plpy_elog.c
@@ -226,6 +226,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");