mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
use the stricter PyMapping_Check (closes #15801)
This commit is contained in:
parent
25cf30faf9
commit
23d49d3e7e
4 changed files with 8 additions and 2 deletions
|
@ -1113,6 +1113,9 @@ class MixinStrUnicodeUserStringTest:
|
||||||
self.checkraises(TypeError, '%10.*f', '__mod__', ('foo', 42.))
|
self.checkraises(TypeError, '%10.*f', '__mod__', ('foo', 42.))
|
||||||
self.checkraises(ValueError, '%10', '__mod__', (42,))
|
self.checkraises(ValueError, '%10', '__mod__', (42,))
|
||||||
|
|
||||||
|
class X(object): pass
|
||||||
|
self.checkraises(TypeError, 'abc', '__mod__', X())
|
||||||
|
|
||||||
def test_floatformatting(self):
|
def test_floatformatting(self):
|
||||||
# float formatting
|
# float formatting
|
||||||
for prec in xrange(100):
|
for prec in xrange(100):
|
||||||
|
|
|
@ -9,6 +9,9 @@ What's New in Python 2.7.4
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #15801: Make sure mappings passed to '%' formatting are actually
|
||||||
|
subscriptable.
|
||||||
|
|
||||||
- Issue #15604: Update uses of PyObject_IsTrue() to check for and handle
|
- Issue #15604: Update uses of PyObject_IsTrue() to check for and handle
|
||||||
errors correctly. Patch by Serhiy Storchaka.
|
errors correctly. Patch by Serhiy Storchaka.
|
||||||
|
|
||||||
|
|
|
@ -4254,7 +4254,7 @@ PyString_Format(PyObject *format, PyObject *args)
|
||||||
arglen = -1;
|
arglen = -1;
|
||||||
argidx = -2;
|
argidx = -2;
|
||||||
}
|
}
|
||||||
if (Py_TYPE(args)->tp_as_mapping && !PyTuple_Check(args) &&
|
if (PyMapping_Check(args) && !PyTuple_Check(args) &&
|
||||||
!PyObject_TypeCheck(args, &PyBaseString_Type))
|
!PyObject_TypeCheck(args, &PyBaseString_Type))
|
||||||
dict = args;
|
dict = args;
|
||||||
while (--fmtcnt >= 0) {
|
while (--fmtcnt >= 0) {
|
||||||
|
|
|
@ -8275,7 +8275,7 @@ PyObject *PyUnicode_Format(PyObject *format,
|
||||||
arglen = -1;
|
arglen = -1;
|
||||||
argidx = -2;
|
argidx = -2;
|
||||||
}
|
}
|
||||||
if (Py_TYPE(args)->tp_as_mapping && !PyTuple_Check(args) &&
|
if (PyMapping_Check(args) && !PyTuple_Check(args) &&
|
||||||
!PyObject_TypeCheck(args, &PyBaseString_Type))
|
!PyObject_TypeCheck(args, &PyBaseString_Type))
|
||||||
dict = args;
|
dict = args;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue