[Python-checkins] CVS: python/dist/src/Modules main.c,1.50,1.51

Jeremy Hylton jhylton@users.sourceforge.net
Wed, 21 Mar 2001 18:48:00 -0800


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

Modified Files:
	main.c 
Log Message:
Extend support for from __future__ import nested_scopes

If a module has a future statement enabling nested scopes, they are
also enable for the exec statement and the functions compile() and
execfile() if they occur in the module.

If Python is run with the -i option, which enters interactive mode
after executing a script, and the script it runs enables nested
scopes, they are also enabled in interactive mode.

XXX The use of -i with -c "from __future__ import nested_scopes" is
not supported.  What's the point?

To support these changes, many function variants have been added to
pythonrun.c.  All the variants names end with Flags and they take an
extra PyCompilerFlags * argument.  It is possible that this complexity
will be eliminated in a future version of the interpreter in which
nested scopes are not optional.




Index: main.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/main.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -r1.50 -r1.51
*** main.c	2001/03/02 06:18:03	1.50
--- main.c	2001/03/22 02:47:57	1.51
***************
*** 100,103 ****
--- 100,104 ----
  	int help = 0;
  	int version = 0;
+ 	PyCompilerFlags cf;
  
  	orig_argc = argc;	/* For Py_GetArgcArgv() */
***************
*** 294,297 ****
--- 295,300 ----
  	}
  
+ 	cf.cf_nested_scopes = 0;
+ 
  	if (command) {
  		sts = PyRun_SimpleString(command) != 0;
***************
*** 310,322 ****
  			}
  		}
! 		sts = PyRun_AnyFileEx(
  			fp,
  			filename == NULL ? "<stdin>" : filename,
! 			filename != NULL) != 0;
  	}
  
  	if (inspect && stdin_is_interactive &&
  	    (filename != NULL || command != NULL))
! 		sts = PyRun_AnyFile(stdin, "<stdin>") != 0;
  
  	Py_Finalize();
--- 313,327 ----
  			}
  		}
! 		/* XXX */
! 		sts = PyRun_AnyFileExFlags(
  			fp,
  			filename == NULL ? "<stdin>" : filename,
! 			filename != NULL, &cf) != 0;
  	}
  
  	if (inspect && stdin_is_interactive &&
  	    (filename != NULL || command != NULL))
! 		/* XXX */
! 		sts = PyRun_AnyFileFlags(stdin, "<stdin>", &cf) != 0;
  
  	Py_Finalize();