File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4853,6 +4853,35 @@ symtable_global(struct symtable *st, node *n)
48534853
48544854 for (i = 1 ; i < NCH (n ); i += 2 ) {
48554855 char * name = STR (CHILD (n , i ));
4856+ int flags ;
4857+
4858+ flags = symtable_lookup (st , name );
4859+ if (flags && flags != DEF_GLOBAL ) {
4860+ char buf [500 ];
4861+ if (flags & DEF_PARAM ) {
4862+ PyErr_Format (PyExc_SyntaxError ,
4863+ "name '%.400s' is local and global" ,
4864+ PyString_AS_STRING (name ));
4865+ set_error_location (st -> st_filename ,
4866+ st -> st_cur -> ste_lineno );
4867+ st -> st_errors ++ ;
4868+ return ;
4869+ } else if (flags & DEF_LOCAL ) {
4870+ sprintf (buf , GLOBAL_AFTER_ASSIGN , name );
4871+ if (PyErr_Warn (PyExc_SyntaxWarning ,
4872+ buf ) < 0 ) {
4873+ /* XXX set line number? */
4874+ st -> st_errors ++ ;
4875+ }
4876+ } else {
4877+ sprintf (buf , GLOBAL_AFTER_USE , name );
4878+ if (PyErr_Warn (PyExc_SyntaxWarning ,
4879+ buf ) < 0 ) {
4880+ /* XXX set line number? */
4881+ st -> st_errors ++ ;
4882+ }
4883+ }
4884+ }
48564885 symtable_add_def (st , name , DEF_GLOBAL );
48574886 }
48584887}
You can’t perform that action at this time.
0 commit comments