bpo-35814: Allow same r.h.s. in annotated assignments as in normal ones (GH-11667)
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 3ed19ff..74590eb 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -445,6 +445,15 @@
exec('X: str', {}, CNS2())
self.assertEqual(nonloc_ns['__annotations__']['x'], str)
+ def test_var_annot_rhs(self):
+ ns = {}
+ exec('x: tuple = 1, 2', ns)
+ self.assertEqual(ns['x'], (1, 2))
+ stmt = ('def f():\n'
+ ' x: int = yield')
+ exec(stmt, ns)
+ self.assertEqual(list(ns['f']()), [None])
+
def test_funcdef(self):
### [decorators] 'def' NAME parameters ['->' test] ':' suite
### decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index ac3899b..19f1782 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -166,7 +166,7 @@
with self.assertRaises(SyntaxError):
exec("x, *y, z: int = range(5)", {}, {})
with self.assertRaises(SyntaxError):
- exec("t: tuple = 1, 2", {}, {})
+ exec("x: int = 1, y = 2", {}, {})
with self.assertRaises(SyntaxError):
exec("u = v: int", {}, {})
with self.assertRaises(SyntaxError):