diff options
author | Christian Heimes <christian@python.org> | 2016-09-23 18:26:30 (GMT) |
---|---|---|
committer | Christian Heimes <christian@python.org> | 2016-09-23 18:26:30 (GMT) |
commit | 517507c6d5d740ab548faddb9e0c57092d19a188 (patch) | |
tree | bee8b69a404b6b0b29a03fa641fc5869e2aa5974 /Python | |
parent | 6f3f3e5ca47ad00d1c5aaa97dc1a790b94dde3e3 (diff) | |
download | cpython-517507c6d5d740ab548faddb9e0c57092d19a188.zip cpython-517507c6d5d740ab548faddb9e0c57092d19a188.tar.gz cpython-517507c6d5d740ab548faddb9e0c57092d19a188.tar.bz2 |
Issue #28100: Refactor error messages, patch by Ivan Levkivskyi
Diffstat (limited to 'Python')
-rw-r--r-- | Python/symtable.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/Python/symtable.c b/Python/symtable.c index f762904..bf30ecc 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -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, |