diff -r 8cee4862fb34 Python/symtable.c --- a/Python/symtable.c Sat Dec 17 13:30:27 2016 -0800 +++ b/Python/symtable.c Sun Dec 18 00:31:09 2016 +0100 @@ -5,6 +5,12 @@ #include "structmember.h" /* error strings used for warnings */ +#define GLOBAL_PARAM \ +"name '%U' is parameter and global" + +#define NONLOCAL_PARAM \ +"name '%U' is parameter and nonlocal" + #define GLOBAL_AFTER_ASSIGN \ "name '%U' is assigned to before global declaration" @@ -463,8 +469,7 @@ if (flags & DEF_GLOBAL) { if (flags & DEF_PARAM) { PyErr_Format(PyExc_SyntaxError, - "name '%U' is parameter and global", - name); + GLOBAL_PARAM, name); return error_at_directive(ste, name); } if (flags & DEF_NONLOCAL) { @@ -483,8 +488,7 @@ if (flags & DEF_NONLOCAL) { if (flags & DEF_PARAM) { PyErr_Format(PyExc_SyntaxError, - "name '%U' is parameter and nonlocal", - name); + NONLOCAL_PARAM, name); return error_at_directive(ste, name); } if (!bound) { @@ -1280,9 +1284,11 @@ long cur = symtable_lookup(st, name); if (cur < 0) VISIT_QUIT(st, 0); - if (cur & (DEF_LOCAL | USE | DEF_ANNOT)) { + if (cur & (DEF_PARAM | DEF_LOCAL | USE | DEF_ANNOT)) { char* msg; - if (cur & USE) { + if (cur & DEF_PARAM) { + msg = GLOBAL_PARAM; + } else if (cur & USE) { msg = GLOBAL_AFTER_USE; } else if (cur & DEF_ANNOT) { msg = GLOBAL_ANNOT; @@ -1311,9 +1317,11 @@ long cur = symtable_lookup(st, name); if (cur < 0) VISIT_QUIT(st, 0); - if (cur & (DEF_LOCAL | USE | DEF_ANNOT)) { + if (cur & (DEF_PARAM | DEF_LOCAL | USE | DEF_ANNOT)) { char* msg; - if (cur & USE) { + if (cur & DEF_PARAM) { + msg = NONLOCAL_PARAM; + } else if (cur & USE) { msg = NONLOCAL_AFTER_USE; } else if (cur & DEF_ANNOT) { msg = NONLOCAL_ANNOT;