aboutsummaryrefslogtreecommitdiff
path: root/contrib/hstore_plpython/hstore_plpython.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/hstore_plpython/hstore_plpython.c')
-rw-r--r--contrib/hstore_plpython/hstore_plpython.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/contrib/hstore_plpython/hstore_plpython.c b/contrib/hstore_plpython/hstore_plpython.c
index 961579a5ea0..310f63c30d4 100644
--- a/contrib/hstore_plpython/hstore_plpython.c
+++ b/contrib/hstore_plpython/hstore_plpython.c
@@ -127,7 +127,13 @@ plpython_to_hstore(PG_FUNCTION_ARGS)
HStore *volatile out;
dict = (PyObject *) PG_GETARG_POINTER(0);
- if (!PyMapping_Check(dict))
+
+ /*
+ * As of Python 3, PyMapping_Check() is unreliable unless one first checks
+ * that the object isn't a sequence. (Cleaner solutions exist, but not
+ * before Python 3.10, which we're not prepared to require yet.)
+ */
+ if (PySequence_Check(dict) || !PyMapping_Check(dict))
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("not a Python mapping")));