mirror of
https://github.com/python/cpython.git
synced 2026-02-26 00:51:11 +00:00
allow any type with __getitem__ to be a mapping for the purposes of % (#15801)
This commit is contained in:
parent
7e2f197a2b
commit
da2c7ebd23
4 changed files with 15 additions and 4 deletions
|
|
@ -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 != '%') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue