]> granicus.if.org Git - python/commitdiff
Issue #28100: Refactor error messages, patch by Ivan Levkivskyi
authorChristian Heimes <christian@python.org>
Fri, 23 Sep 2016 18:26:30 +0000 (20:26 +0200)
committerChristian Heimes <christian@python.org>
Fri, 23 Sep 2016 18:26:30 +0000 (20:26 +0200)
Python/symtable.c

index f762904240f5521ffe1ccdc13bd0f641c4ef0033..bf30eccdabbdb20f985fe1609eb8a42d24297703 100644 (file)
@@ -1282,15 +1282,13 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
                 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 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
                 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,