Kaydet (Commit) 517507c6 authored tarafından Christian Heimes's avatar Christian Heimes

Issue #28100: Refactor error messages, patch by Ivan Levkivskyi

üst 6f3f3e5c
...@@ -1282,15 +1282,13 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) ...@@ -1282,15 +1282,13 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
VISIT_QUIT(st, 0); VISIT_QUIT(st, 0);
if (cur & (DEF_LOCAL | USE | DEF_ANNOT)) { if (cur & (DEF_LOCAL | USE | DEF_ANNOT)) {
char* msg; char* msg;
if (cur & DEF_ANNOT) { if (cur & USE) {
msg = GLOBAL_AFTER_USE;
} else if (cur & DEF_ANNOT) {
msg = GLOBAL_ANNOT; msg = GLOBAL_ANNOT;
} } else { /* DEF_LOCAL */
if (cur & DEF_LOCAL) {
msg = GLOBAL_AFTER_ASSIGN; msg = GLOBAL_AFTER_ASSIGN;
} }
else {
msg = GLOBAL_AFTER_USE;
}
PyErr_Format(PyExc_SyntaxError, PyErr_Format(PyExc_SyntaxError,
msg, name); msg, name);
PyErr_SyntaxLocationObject(st->st_filename, PyErr_SyntaxLocationObject(st->st_filename,
...@@ -1315,15 +1313,13 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) ...@@ -1315,15 +1313,13 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
VISIT_QUIT(st, 0); VISIT_QUIT(st, 0);
if (cur & (DEF_LOCAL | USE | DEF_ANNOT)) { if (cur & (DEF_LOCAL | USE | DEF_ANNOT)) {
char* msg; char* msg;
if (cur & DEF_ANNOT) { if (cur & USE) {
msg = NONLOCAL_AFTER_USE;
} else if (cur & DEF_ANNOT) {
msg = NONLOCAL_ANNOT; msg = NONLOCAL_ANNOT;
} } else { /* DEF_LOCAL */
if (cur & DEF_LOCAL) {
msg = NONLOCAL_AFTER_ASSIGN; msg = NONLOCAL_AFTER_ASSIGN;
} }
else {
msg = NONLOCAL_AFTER_USE;
}
PyErr_Format(PyExc_SyntaxError, msg, name); PyErr_Format(PyExc_SyntaxError, msg, name);
PyErr_SyntaxLocationObject(st->st_filename, PyErr_SyntaxLocationObject(st->st_filename,
s->lineno, s->lineno,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment