[Python-checkins] cpython (merge 3.2 -> default): merge 3.2 (#15801)

benjamin.peterson python-checkins at python.org
Wed Aug 29 00:02:30 CEST 2012


http://hg.python.org/cpython/rev/263d09ce3e9e
changeset: 78794:263d09ce3e9e
parent: 78790:454dceb5fd56
parent: 78793:4d431e719646
user: Benjamin Peterson <benjamin at python.org>
date: Tue Aug 28 18:01:45 2012 -0400
summary:
 merge 3.2 (#15801)
files:
 Lib/test/string_tests.py | 3 +++
 Misc/NEWS | 3 +++
 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
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -1206,6 +1206,9 @@
 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):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -71,6 +71,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 --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -13461,8 +13461,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) {
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

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