Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 517507c

Browse files
committed
Issue #28100: Refactor error messages, patch by Ivan Levkivskyi
1 parent 6f3f3e5 commit 517507c

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

Python/symtable.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,15 +1282,13 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
12821282
VISIT_QUIT(st, 0);
12831283
if (cur & (DEF_LOCAL | USE | DEF_ANNOT)) {
12841284
char* msg;
1285-
if (cur & DEF_ANNOT) {
1285+
if (cur & USE) {
1286+
msg = GLOBAL_AFTER_USE;
1287+
} else if (cur & DEF_ANNOT) {
12861288
msg = GLOBAL_ANNOT;
1287-
}
1288-
if (cur & DEF_LOCAL) {
1289+
} else { /* DEF_LOCAL */
12891290
msg = GLOBAL_AFTER_ASSIGN;
12901291
}
1291-
else {
1292-
msg = GLOBAL_AFTER_USE;
1293-
}
12941292
PyErr_Format(PyExc_SyntaxError,
12951293
msg, name);
12961294
PyErr_SyntaxLocationObject(st->st_filename,
@@ -1315,15 +1313,13 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
13151313
VISIT_QUIT(st, 0);
13161314
if (cur & (DEF_LOCAL | USE | DEF_ANNOT)) {
13171315
char* msg;
1318-
if (cur & DEF_ANNOT) {
1316+
if (cur & USE) {
1317+
msg = NONLOCAL_AFTER_USE;
1318+
} else if (cur & DEF_ANNOT) {
13191319
msg = NONLOCAL_ANNOT;
1320-
}
1321-
if (cur & DEF_LOCAL) {
1320+
} else { /* DEF_LOCAL */
13221321
msg = NONLOCAL_AFTER_ASSIGN;
13231322
}
1324-
else {
1325-
msg = NONLOCAL_AFTER_USE;
1326-
}
13271323
PyErr_Format(PyExc_SyntaxError, msg, name);
13281324
PyErr_SyntaxLocationObject(st->st_filename,
13291325
s->lineno,

0 commit comments

Comments
 (0)