mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
bpo-35169: Improve error messages for forbidden assignments. (GH-10342)
This commit is contained in:
parent
6c48bf2d9e
commit
97f1efb606
6 changed files with 140 additions and 96 deletions
|
@ -73,11 +73,11 @@ class DictComprehensionTest(unittest.TestCase):
|
|||
self.assertEqual(v, "Local variable")
|
||||
|
||||
def test_illegal_assignment(self):
|
||||
with self.assertRaisesRegex(SyntaxError, "can't assign"):
|
||||
with self.assertRaisesRegex(SyntaxError, "cannot assign"):
|
||||
compile("{x: y for y, x in ((1, 2), (3, 4))} = 5", "<test>",
|
||||
"exec")
|
||||
|
||||
with self.assertRaisesRegex(SyntaxError, "can't assign"):
|
||||
with self.assertRaisesRegex(SyntaxError, "cannot assign"):
|
||||
compile("{x: y for y, x in ((1, 2), (3, 4))} += 5", "<test>",
|
||||
"exec")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue