self.assertTrue(st4.lookup('x').is_local())
self.assertFalse(st4.lookup('x').is_annotated())
+ # Test that annotations in the global scope are valid after the
+ # variable is declared as nonlocal.
+ st5 = symtable.symtable('global x\nx: int', 'test', 'exec')
+ self.assertTrue(st5.lookup("x").is_global())
+
+ # Test that annotations for nonlocals are valid after the
+ # variable is declared as nonlocal.
+ st6 = symtable.symtable('def g():\n'
+ ' x = 2\n'
+ ' def f():\n'
+ ' nonlocal x\n'
+ ' x: int',
+ 'test', 'exec')
+
def test_imported(self):
self.assertTrue(self.top.lookup("sys").is_imported())
VISIT_QUIT(st, 0);
}
if ((cur & (DEF_GLOBAL | DEF_NONLOCAL))
+ && (st->st_cur->ste_symbols != st->st_global)
&& s->v.AnnAssign.simple) {
PyErr_Format(PyExc_SyntaxError,
cur & DEF_GLOBAL ? GLOBAL_ANNOT : NONLOCAL_ANNOT,