[Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.227,2.228

Tim Peters tim_one@users.sourceforge.net
Fri, 17 Aug 2001 15:11:30 -0700


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

Modified Files:
	bltinmodule.c 
Log Message:
A fiddled version of the rest of Michael Hudson's SF patch
    #449043 supporting __future__ in simulated shells
which implements PEP 264.


Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.227
retrieving revision 2.228
diff -C2 -d -r2.227 -r2.228
*** bltinmodule.c	2001/08/17 18:39:25	2.227
--- bltinmodule.c	2001/08/17 22:11:27	2.228
***************
*** 378,385 ****
  	char *startstr;
  	int start;
  	PyCompilerFlags cf;
  
! 	if (!PyArg_ParseTuple(args, "sss:compile", &str, &filename, &startstr))
  		return NULL;
  	if (strcmp(startstr, "exec") == 0)
  		start = Py_file_input;
--- 378,389 ----
  	char *startstr;
  	int start;
+ 	int dont_inherit = 0;
+ 	int supplied_flags = 0;
  	PyCompilerFlags cf;
  
! 	if (!PyArg_ParseTuple(args, "sss|ii:compile", &str, &filename, 
! 			      &startstr, &supplied_flags, &dont_inherit))
  		return NULL;
+ 
  	if (strcmp(startstr, "exec") == 0)
  		start = Py_file_input;
***************
*** 393,405 ****
  		return NULL;
  	}
! 	cf.cf_flags = 0;
! 	if (PyEval_MergeCompilerFlags(&cf))
! 		return Py_CompileStringFlags(str, filename, start, &cf);
! 	else
! 		return Py_CompileString(str, filename, start);
  }
  
  static char compile_doc[] =
! "compile(source, filename, mode) -> code object\n\
  \n\
  Compile the source string (a Python module, statement or expression)\n\
--- 397,417 ----
  		return NULL;
  	}
! 
! 	if (supplied_flags & ~(PyCF_MASK | PyCF_MASK_OBSOLETE)) {
! 		PyErr_SetString(PyExc_ValueError,
! 				"compile(): unrecognised flags");
! 		return NULL;
! 	}
! 	/* XXX Warn if (supplied_flags & PyCF_MASK_OBSOLETE) != 0? */
! 
! 	cf.cf_flags = supplied_flags;
! 	if (!dont_inherit) {
! 		PyEval_MergeCompilerFlags(&cf);
! 	}
! 	return Py_CompileStringFlags(str, filename, start, &cf);
  }
  
  static char compile_doc[] =
! "compile(source, filename, mode[, flags[, dont_inherit]]) -> code object\n\
  \n\
  Compile the source string (a Python module, statement or expression)\n\
***************
*** 407,411 ****
  The filename will be used for run-time error messages.\n\
  The mode must be 'exec' to compile a module, 'single' to compile a\n\
! single (interactive) statement, or 'eval' to compile an expression.";
  
  
--- 419,429 ----
  The filename will be used for run-time error messages.\n\
  The mode must be 'exec' to compile a module, 'single' to compile a\n\
! single (interactive) statement, or 'eval' to compile an expression.\n\
! The flags argument, if present, controls which future statements influence\n\
! the compilation of the code.\n\
! The dont_inherit argument, if non-zero, stops the compilation inheriting\n\
! the effects of any future statements in effect in the code calling\n\
! compile; if absent or zero these statements do influence the compilation,\n\
! in addition to any features explicitly specified.";