diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2002-11-12 23:01:12 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2002-11-12 23:01:12 (GMT) |
commit | 80a1bf4b5db4880f01d30b89ab5f6c436d50c8e6 (patch) | |
tree | b8d9f619c12790ad63bf1f044b7e08fd4aa29bf8 /Objects | |
parent | 0b9e3f750cc91e83d9614dd941545a8b29fa248a (diff) | |
download | cpython-80a1bf4b5db4880f01d30b89ab5f6c436d50c8e6.zip cpython-80a1bf4b5db4880f01d30b89ab5f6c436d50c8e6.tar.gz cpython-80a1bf4b5db4880f01d30b89ab5f6c436d50c8e6.tar.bz2 |
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.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/stringobject.c | 3 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 35b4b47..bf8bad5 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -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 != '%') { diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index c1cdebc..12846bf 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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) { |