[Python-checkins] cpython (3.6): Issue #28100: Refactor error messages, patch by Ivan Levkivskyi

christian.heimes python-checkins at python.org
Fri Sep 23 14:26:53 EDT 2016


https://hg.python.org/cpython/rev/966b57281536
changeset:   104037:966b57281536
branch:      3.6
parent:      104035:ab8e3dfee2f5
user:        Christian Heimes <christian at python.org>
date:        Fri Sep 23 20:26:30 2016 +0200
summary:
  Issue #28100: Refactor error messages, patch by Ivan Levkivskyi

files:
  Python/symtable.c |  20 ++++++++------------
  1 files changed, 8 insertions(+), 12 deletions(-)


diff --git a/Python/symtable.c b/Python/symtable.c
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -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,

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list