summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2013-01-05 13:49:19 +0000
committerPeter Eisentraut2013-01-05 13:50:58 +0000
commit7e938e3c56590899bcfa587ad0220869cb9be951 (patch)
tree5d250f9f98762274d220bdeda5473eea4cf98271
parent9e6df606197395a5fea6efb13f6f443f420e7b39 (diff)
Revert "PL/Python: Remove workaround for returning booleans in Python <2.3"
This reverts commit be0dfbad3671ed2503a2a661e70b48c5b364e069. The previous information that Py_RETURN_TRUE and Py_RETURN_FALSE are supported in Python 2.3 is wrong. They require Python 2.4. Update the comment about that.
-rw-r--r--src/pl/plpython/plpy_typeio.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/pl/plpython/plpy_typeio.c b/src/pl/plpython/plpy_typeio.c
index 74da5180f1b..8f2367d3042 100644
--- a/src/pl/plpython/plpy_typeio.c
+++ b/src/pl/plpython/plpy_typeio.c
@@ -492,9 +492,15 @@ PLy_input_datum_func2(PLyDatumToOb *arg, Oid typeOid, HeapTuple typeTup)
static PyObject *
PLyBool_FromBool(PLyDatumToOb *arg, Datum d)
{
+ /*
+ * We would like to use Py_RETURN_TRUE and Py_RETURN_FALSE here for
+ * generating SQL from trigger functions, but those are only supported in
+ * Python >= 2.4, and we support older versions.
+ * http://docs.python.org/api/boolObjects.html
+ */
if (DatumGetBool(d))
- Py_RETURN_TRUE;
- Py_RETURN_FALSE;
+ return PyBool_FromLong(1);
+ return PyBool_FromLong(0);
}
static PyObject *