diff -r b995b1f52975 Python/symtable.c --- a/Python/symtable.c Wed Sep 21 15:56:57 2016 +0300 +++ b/Python/symtable.c Wed Sep 21 17:29:09 2016 +0200 @@ -1282,15 +1282,13 @@ VISIT_QUIT(st, 0); if (cur & (DEF_LOCAL | USE | DEF_ANNOT)) { char* msg; - if (cur & DEF_ANNOT) { + if (cur & USE) { + msg = GLOBAL_AFTER_USE; + } else if (cur & DEF_ANNOT) { msg = GLOBAL_ANNOT; - } - if (cur & DEF_LOCAL) { + } else { /* DEF_LOCAL */ msg = GLOBAL_AFTER_ASSIGN; } - else { - msg = GLOBAL_AFTER_USE; - } PyErr_Format(PyExc_SyntaxError, msg, name); PyErr_SyntaxLocationObject(st->st_filename, @@ -1315,15 +1313,13 @@ VISIT_QUIT(st, 0); if (cur & (DEF_LOCAL | USE | DEF_ANNOT)) { char* msg; - if (cur & DEF_ANNOT) { + if (cur & USE) { + msg = NONLOCAL_AFTER_USE; + } else if (cur & DEF_ANNOT) { msg = NONLOCAL_ANNOT; - } - if (cur & DEF_LOCAL) { + } else { /* DEF_LOCAL */ msg = NONLOCAL_AFTER_ASSIGN; } - else { - msg = NONLOCAL_AFTER_USE; - } PyErr_Format(PyExc_SyntaxError, msg, name); PyErr_SyntaxLocationObject(st->st_filename, s->lineno,