summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gi/pygi-argument.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index c6b62a0..8fbb837 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -532,7 +532,18 @@ check_number_release:
GITypeInfo *value_type_info;
Py_ssize_t i;
+#if PY_MAJOR_VERSION >= 3
+ /*
+ In Python 3, PyMapping_Check returns 1 for lists and strings
+ (this is http://bugs.python.org/issue5945), but PyMapping_Keys
+ fails with a "AttributeError: keys"
+
+ So for Python 3 we require the object to be a dictionary:
+ */
+ if (!PyDict_Check(object)) {
+#else
if (!PyMapping_Check(object)) {
+#endif
PyErr_Format(PyExc_TypeError, "Must be mapping, not %s",
object->ob_type->tp_name);
retval = 0;