allow any type with __getitem__ to be a mapping for the purposes of % (#15801)

This commit is contained in:
Benjamin Peterson 2013-03-23 22:32:00 -05:00
parent 7e2f197a2b
commit da2c7ebd23
4 changed files with 15 additions and 4 deletions

View file

@ -1130,6 +1130,10 @@ class MixinStrUnicodeUserStringTest:
class X(object): pass
self.checkraises(TypeError, 'abc', '__mod__', X())
class X(Exception):
def __getitem__(self, k):
return k
self.checkequal('melon apple', '%(melon)s %(apple)s', '__mod__', X())
def test_floatformatting(self):
# float formatting