mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Fix SF # 635969, No error "not all arguments converted"
When mwh added extended slicing, strings and unicode became mappings. Thus, dict was set which prevented an error when doing: newstr = 'format without a percent' % string_value This fix raises an exception again when there are no formats and % with a string value.
This commit is contained in:
parent
0b9e3f750c
commit
80a1bf4b5d
3 changed files with 12 additions and 2 deletions
|
@ -3622,7 +3622,8 @@ PyString_Format(PyObject *format, PyObject *args)
|
|||
arglen = -1;
|
||||
argidx = -2;
|
||||
}
|
||||
if (args->ob_type->tp_as_mapping && !PyTuple_Check(args))
|
||||
if (args->ob_type->tp_as_mapping && !PyTuple_Check(args) &&
|
||||
!PyObject_TypeCheck(args, &PyBaseString_Type))
|
||||
dict = args;
|
||||
while (--fmtcnt >= 0) {
|
||||
if (*fmt != '%') {
|
||||
|
|
|
@ -6181,7 +6181,8 @@ PyObject *PyUnicode_Format(PyObject *format,
|
|||
arglen = -1;
|
||||
argidx = -2;
|
||||
}
|
||||
if (args->ob_type->tp_as_mapping && !PyTuple_Check(args))
|
||||
if (args->ob_type->tp_as_mapping && !PyTuple_Check(args) &&
|
||||
!PyObject_TypeCheck(args, &PyBaseString_Type))
|
||||
dict = args;
|
||||
|
||||
while (--fmtcnt >= 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue