bpo-45045: Optimize mapping patterns of structural pattern matching (GH-28043)

This commit is contained in:
Dong-hee Na 2021-08-30 10:02:32 +00:00 committed by GitHub
parent 94b2639fad
commit e6497fe698
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 6 deletions

View file

@ -2641,6 +2641,19 @@ class TestPatma(unittest.TestCase):
self.assertEqual(f((False, range(-1, -11, -1), True)), alts[3])
self.assertEqual(f((False, range(10, 20), True)), alts[4])
def test_patma_248(self):
class C(dict):
@staticmethod
def get(key, default=None):
return 'bar'
x = C({'foo': 'bar'})
match x:
case {'foo': bar}:
y = bar
self.assertEqual(y, 'bar')
class TestSyntaxErrors(unittest.TestCase):