summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2013-03-24 03:32:00 (GMT)
committerBenjamin Peterson <benjamin@python.org>2013-03-24 03:32:00 (GMT)
commitda2c7ebd234fc904f6d6de2191eb5f72e8992c95 (patch)
treefe5ea090417c5bb6a82e9ea3a7d1421b5227127b /Objects
parent7e2f197a2bc3d15ff8c504154f48a3c2435c992f (diff)
downloadcpython-da2c7ebd234fc904f6d6de2191eb5f72e8992c95.zip
cpython-da2c7ebd234fc904f6d6de2191eb5f72e8992c95.tar.gz
cpython-da2c7ebd234fc904f6d6de2191eb5f72e8992c95.tar.bz2
allow any type with __getitem__ to be a mapping for the purposes of % (#15801)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/stringobject.c4
-rw-r--r--Objects/unicodeobject.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 7871323..1209197 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -4257,8 +4257,8 @@ PyString_Format(PyObject *format, PyObject *args)
arglen = -1;
argidx = -2;
}
- if (PyMapping_Check(args) && !PyTuple_Check(args) &&
- !PyObject_TypeCheck(args, &PyBaseString_Type))
+ if (Py_TYPE(args)->tp_as_mapping && Py_TYPE(args)->tp_as_mapping->mp_subscript &&
+ !PyTuple_Check(args) && !PyObject_TypeCheck(args, &PyBaseString_Type))
dict = args;
while (--fmtcnt >= 0) {
if (*fmt != '%') {
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 981a98b..0ead06f 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8287,8 +8287,8 @@ PyObject *PyUnicode_Format(PyObject *format,
arglen = -1;
argidx = -2;
}
- if (PyMapping_Check(args) && !PyTuple_Check(args) &&
- !PyObject_TypeCheck(args, &PyBaseString_Type))
+ if (Py_TYPE(args)->tp_as_mapping && Py_TYPE(args)->tp_as_mapping->mp_subscript &&
+ !PyTuple_Check(args) && !PyObject_TypeCheck(args, &PyBaseString_Type))
dict = args;
while (--fmtcnt >= 0) {