changeset: 78793:4d431e719646 branch: 3.2 parent: 78787:5c13bd7f6256 user: Benjamin Peterson date: Tue Aug 28 17:55:35 2012 -0400 files: Lib/test/string_tests.py Misc/NEWS Objects/unicodeobject.c description: use the stricter PyMapping_Check (closes #15801) diff -r 5c13bd7f6256 -r 4d431e719646 Lib/test/string_tests.py --- a/Lib/test/string_tests.py Tue Aug 28 19:07:38 2012 +0200 +++ b/Lib/test/string_tests.py Tue Aug 28 17:55:35 2012 -0400 @@ -1142,6 +1142,9 @@ self.checkraises(TypeError, '%10.*f', '__mod__', ('foo', 42.)) self.checkraises(ValueError, '%10', '__mod__', (42,)) + class X(object): pass + self.checkraises(TypeError, 'abc', '__mod__', X()) + def test_floatformatting(self): # float formatting for prec in range(100): diff -r 5c13bd7f6256 -r 4d431e719646 Misc/NEWS --- a/Misc/NEWS Tue Aug 28 19:07:38 2012 +0200 +++ b/Misc/NEWS Tue Aug 28 17:55:35 2012 -0400 @@ -12,6 +12,9 @@ - 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 -r 5c13bd7f6256 -r 4d431e719646 Objects/unicodeobject.c --- a/Objects/unicodeobject.c Tue Aug 28 19:07:38 2012 +0200 +++ b/Objects/unicodeobject.c Tue Aug 28 17:55:35 2012 -0400 @@ -9504,8 +9504,7 @@ 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) {

AltStyle によって変換されたページ (->オリジナル) /