[3.10] bpo-44589: raise a SyntaxError when mapping patterns have duplicate literal keys (GH-27131) (GH-27157)



(cherry picked from commit 2693132292b2acf381ac6fa729bf3acf41d9d72b)


Co-authored-by: Jack DeVries <58614260+jdevries3133@users.noreply.github.com>

Automerge-Triggered-By: GH:brandtbucher
diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py
index a8889ca..69a648a 100644
--- a/Lib/test/test_patma.py
+++ b/Lib/test/test_patma.py
@@ -2901,6 +2901,40 @@ def test_wildcard_makes_remaining_patterns_unreachable_5(self):
                 pass
         """)
 
+    def test_mapping_pattern_duplicate_key(self):
+        self.assert_syntax_error("""
+        match ...:
+            case {"a": _, "a": _}:
+                pass
+        """)
+
+    def test_mapping_pattern_duplicate_key_edge_case0(self):
+        self.assert_syntax_error("""
+        match ...:
+            case {0: _, False: _}:
+                pass
+        """)
+
+    def test_mapping_pattern_duplicate_key_edge_case1(self):
+        self.assert_syntax_error("""
+        match ...:
+            case {0: _, 0.0: _}:
+                pass
+        """)
+
+    def test_mapping_pattern_duplicate_key_edge_case2(self):
+        self.assert_syntax_error("""
+        match ...:
+            case {0: _, -0: _}:
+                pass
+        """)
+
+    def test_mapping_pattern_duplicate_key_edge_case3(self):
+        self.assert_syntax_error("""
+        match ...:
+            case {0: _, 0j: _}:
+                pass
+        """)
 
 class TestTypeErrors(unittest.TestCase):
 
@@ -3008,17 +3042,6 @@ class Class:
 
 class TestValueErrors(unittest.TestCase):
 
-    def test_mapping_pattern_checks_duplicate_key_0(self):
-        x = {"a": 0, "b": 1}
-        w = y = z = None
-        with self.assertRaises(ValueError):
-            match x:
-                case {"a": y, "a": z}:
-                    w = 0
-        self.assertIs(w, None)
-        self.assertIs(y, None)
-        self.assertIs(z, None)
-
     def test_mapping_pattern_checks_duplicate_key_1(self):
         class Keys:
             KEY = "a"