[Python-checkins] CVS: python/dist/src/Python future.c,2.10,2.11

Jeremy Hylton jhylton@users.sourceforge.net
2001年8月20日 13:32:35 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv7670/Python
Modified Files:
	future.c 
Log Message:
Fix SF bug [ #450245 ] Error in parsing future stmts
Check return value from future_parse() in for loop for file_input to
accomodate multiple future statements on separate lines.
Add several comments explaining how the code works.
Remove out-dated XXX comment.
Index: future.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/future.c,v
retrieving revision 2.10
retrieving revision 2.11
diff -C2 -d -r2.10 -r2.11
*** future.c	2001年08月10日 21:41:33	2.10
--- future.c	2001年08月20日 20:32:33	2.11
***************
*** 9,12 ****
--- 9,15 ----
 #define FUTURE_IMPORT_STAR "future statement does not support import *"
 
+ /* FUTURE_POSSIBLE() is provided to accomodate doc strings, which is
+ the only statement that can occur before a future statement.
+ */
 #define FUTURE_POSSIBLE(FF) ((FF)->ff_last_lineno == -1)
 
***************
*** 58,62 ****
 			"beginning of the file");
 	PyErr_SyntaxLocation(filename, n->n_lineno);
- 	/* XXX set filename and lineno */
 }
 
--- 61,64 ----
***************
*** 76,80 ****
 */
 
! /* future_parse() return values:
 -1 indicates an error occurred, e.g. unknown feature name
 0 indicates no feature was found
--- 78,87 ----
 */
 
! /* future_parse() finds future statements at the beginnning of a
! module. The function calls itself recursively, rather than
! factoring out logic for different kinds of statements into
! different routines.
! 
! Return values:
 -1 indicates an error occurred, e.g. unknown feature name
 0 indicates no feature was found
***************
*** 98,106 ****
 
 	case file_input:
 		for (i = 0; i < NCH(n); i++) {
 			node *ch = CHILD(n, i);
 			if (TYPE(ch) == stmt) {
 				r = future_parse(ff, ch, filename);
! 				if (!FUTURE_POSSIBLE(ff))
 					return r;
 			}
--- 105,121 ----
 
 	case file_input:
+ 		/* Check each statement in the file, starting with the
+ 		 first, and continuing until the first statement
+ 		 that isn't a future statement.
+ 		*/
 		for (i = 0; i < NCH(n); i++) {
 			node *ch = CHILD(n, i);
 			if (TYPE(ch) == stmt) {
 				r = future_parse(ff, ch, filename);
! 				/* Need to check both conditions below
! 				 to accomodate doc strings, which
! 				 causes r < 0.
! 				*/
! 				if (r < 1 && !FUTURE_POSSIBLE(ff))
 					return r;
 			}

AltStyle によって変換されたページ (->オリジナル) /