allow any type with __getitem__ to be a mapping for the purposes of % (#15801)
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index d3412d0..d5ab6ae 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -1130,6 +1130,10 @@
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