[Python-checkins] CVS: python/dist/src/Python compile.c,2.177,2.178

Guido van Rossum gvanrossum@users.sourceforge.net
Wed, 28 Feb 2001 13:55:41 -0800


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv30083

Modified Files:
	compile.c 
Log Message:
Use the new PyErr_WarnExplicit() API to issue better warnings for
global after assign / use.

Note: I'm not updating the PyErr_Warn() call for import * / exec
combined with a function, because I can't trigger it with an example.
Jeremy, just follow the example of the call to PyErr_WarnExplicit()
that I *did* include.


Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.177
retrieving revision 2.178
diff -C2 -r2.177 -r2.178
*** compile.c	2001/02/28 17:47:12	2.177
--- compile.c	2001/02/28 21:55:38	2.178
***************
*** 4831,4846 ****
  				st->st_errors++;
  				return;
! 			} else if (flags & DEF_LOCAL) {
! 				sprintf(buf, GLOBAL_AFTER_ASSIGN, name);
! 				if (PyErr_Warn(PyExc_SyntaxWarning,
! 					       buf) < 0) {
! 					/* XXX set line number? */
! 					st->st_errors++;
! 				}
! 			} else {
! 				sprintf(buf, GLOBAL_AFTER_USE, name);
! 				if (PyErr_Warn(PyExc_SyntaxWarning,
! 					       buf) < 0) {
! 					/* XXX set line number? */
  					st->st_errors++;
  				}
--- 4831,4855 ----
  				st->st_errors++;
  				return;
! 			}
! 			else {
! 				if (flags & DEF_LOCAL)
! 					sprintf(buf, GLOBAL_AFTER_ASSIGN,
! 						name);
! 				else
! 					sprintf(buf, GLOBAL_AFTER_USE, name);
! 				if (PyErr_WarnExplicit(PyExc_SyntaxWarning,
! 						       buf, st->st_filename,
! 						       st->st_cur->ste_lineno,
! 						       NULL, NULL) < 0)
! 				{
! 					if (PyErr_ExceptionMatches(
! 						PyExc_SyntaxWarning))
! 					{
! 						PyErr_SetString(
! 						    PyExc_SyntaxError, buf);
! 						PyErr_SyntaxLocation(
! 						    st->st_filename,
! 						    st->st_cur->ste_lineno);
! 					}
  					st->st_errors++;
  				}