99#include "structmember.h"
1010
1111/* error strings used for warnings */
12+ #define GLOBAL_PARAM \
13+ "name '%U' is parameter and global"
14+
15+ #define NONLOCAL_PARAM \
16+ "name '%U' is parameter and nonlocal"
17+
1218#define GLOBAL_AFTER_ASSIGN \
1319"name '%U' is assigned to before global declaration"
1420
@@ -465,12 +471,6 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags,
465471 PyObject * global )
466472{
467473 if (flags & DEF_GLOBAL ) {
468- if (flags & DEF_PARAM ) {
469- PyErr_Format (PyExc_SyntaxError ,
470- "name '%U' is parameter and global" ,
471- name );
472- return error_at_directive (ste , name );
473- }
474474 if (flags & DEF_NONLOCAL ) {
475475 PyErr_Format (PyExc_SyntaxError ,
476476 "name '%U' is nonlocal and global" ,
@@ -485,12 +485,6 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags,
485485 return 1 ;
486486 }
487487 if (flags & DEF_NONLOCAL ) {
488- if (flags & DEF_PARAM ) {
489- PyErr_Format (PyExc_SyntaxError ,
490- "name '%U' is parameter and nonlocal" ,
491- name );
492- return error_at_directive (ste , name );
493- }
494488 if (!bound ) {
495489 PyErr_Format (PyExc_SyntaxError ,
496490 "nonlocal declaration not allowed at module level" );
@@ -1284,9 +1278,11 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
12841278 long cur = symtable_lookup (st , name );
12851279 if (cur < 0 )
12861280 VISIT_QUIT (st , 0 );
1287- if (cur & (DEF_LOCAL | USE | DEF_ANNOT )) {
1288- char * msg ;
1289- if (cur & USE ) {
1281+ if (cur & (DEF_PARAM | DEF_LOCAL | USE | DEF_ANNOT )) {
1282+ const char * msg ;
1283+ if (cur & DEF_PARAM ) {
1284+ msg = GLOBAL_PARAM ;
1285+ } else if (cur & USE ) {
12901286 msg = GLOBAL_AFTER_USE ;
12911287 } else if (cur & DEF_ANNOT ) {
12921288 msg = GLOBAL_ANNOT ;
@@ -1315,9 +1311,11 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
13151311 long cur = symtable_lookup (st , name );
13161312 if (cur < 0 )
13171313 VISIT_QUIT (st , 0 );
1318- if (cur & (DEF_LOCAL | USE | DEF_ANNOT )) {
1319- char * msg ;
1320- if (cur & USE ) {
1314+ if (cur & (DEF_PARAM | DEF_LOCAL | USE | DEF_ANNOT )) {
1315+ const char * msg ;
1316+ if (cur & DEF_PARAM ) {
1317+ msg = NONLOCAL_PARAM ;
1318+ } else if (cur & USE ) {
13211319 msg = NONLOCAL_AFTER_USE ;
13221320 } else if (cur & DEF_ANNOT ) {
13231321 msg = NONLOCAL_ANNOT ;
0 commit comments