diff options
-rw-r--r-- | Lib/test/string_tests.py | 3 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 3 |
3 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py index 8da3e77..e4688d0 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -1206,6 +1206,9 @@ class MixinStrUnicodeUserStringTest: self.checkraises(ValueError, '%%%df' % (2**64), '__mod__', (3.2)) self.checkraises(ValueError, '%%.%df' % (2**64), '__mod__', (3.2)) + class X(object): pass + self.checkraises(TypeError, 'abc', '__mod__', X()) + def test_floatformatting(self): # float formatting for prec in range(100): @@ -71,6 +71,9 @@ Core and Builtins - Issue #15761: Fix crash when PYTHONEXECUTABLE is set on Mac OS X. +- Issue #15801: Make sure mappings passed to '%' formatting are actually + subscriptable. + - Issue #15726: Fix incorrect bounds checking in PyState_FindModule. Patch by Robin Schreiber. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 773a9be..af4a13a 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -13461,8 +13461,7 @@ PyUnicode_Format(PyObject *format, PyObject *args) arglen = -1; argidx = -2; } - if (Py_TYPE(args)->tp_as_mapping && !PyTuple_Check(args) && - !PyUnicode_Check(args)) + if (PyMapping_Check(args) && !PyTuple_Check(args) && !PyUnicode_Check(args)) dict = args; while (--fmtcnt >= 0) { |