bpo-30978: str.format_map() now passes key lookup exceptions through. (#2790)

Previously any exception was replaced with a KeyError exception.
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 0ea5a20..e9c07a0 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -468,7 +468,7 @@
             m[(0,)]
         with self.assertRaisesRegex(IndexError, 'no such group'):
             m[(0, 1)]
-        with self.assertRaisesRegex(KeyError, 'a2'):
+        with self.assertRaisesRegex(IndexError, 'no such group'):
             'a1={a2}'.format_map(m)
 
         m = pat.match('ac')
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 506f071..341007b 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -1278,6 +1278,13 @@
         self.assertRaises(ValueError, '{}'.format_map, 'a')
         self.assertRaises(ValueError, '{a} {}'.format_map, {"a" : 2, "b" : 1})
 
+        class BadMapping:
+            def __getitem__(self, key):
+                return 1/0
+        self.assertRaises(KeyError, '{a}'.format_map, {})
+        self.assertRaises(TypeError, '{a}'.format_map, [])
+        self.assertRaises(ZeroDivisionError, '{a}'.format_map, BadMapping())
+
     def test_format_huge_precision(self):
         format_string = ".{}f".format(sys.maxsize + 1)
         with self.assertRaises(ValueError):