[Python-checkins] CVS: python/dist/src/Python ceval.c,2.233,2.234 compile.c,2.190,2.191

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


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

Modified Files:
	ceval.c compile.c 
Log Message:
If a code object is compiled with nested scopes, define the CO_NESTED flag.

Add PyEval_GetNestedScopes() which returns a non-zero value if the
code for the current interpreter frame has CO_NESTED defined.


Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.233
retrieving revision 2.234
diff -C2 -r2.233 -r2.234
*** ceval.c	2001/03/21 19:17:22	2.233
--- ceval.c	2001/03/22 02:32:48	2.234
***************
*** 2668,2671 ****
--- 2668,2679 ----
  
  int
+ PyEval_GetNestedScopes(void)
+ {
+ 	PyFrameObject *current_frame = PyThreadState_Get()->frame;
+ 	return current_frame == NULL ? 0 : 
+ 	    current_frame->f_code->co_flags & CO_NESTED;
+ }
+ 
+ int
  Py_FlushLine(void)
  {
***************
*** 3449,3453 ****
  		FILE *fp = PyFile_AsFile(prog);
  		char *name = PyString_AsString(PyFile_Name(prog));
! 		v = PyRun_File(fp, name, Py_file_input, globals, locals);
  	}
  	else {
--- 3457,3461 ----
  		FILE *fp = PyFile_AsFile(prog);
  		char *name = PyString_AsString(PyFile_Name(prog));
! 		v = PyRun_File(fp, name, Py_file_input, globals, locals); 
  	}
  	else {

Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.190
retrieving revision 2.191
diff -C2 -r2.190 -r2.191
*** compile.c	2001/03/21 19:01:33	2.190
--- compile.c	2001/03/22 02:32:48	2.191
***************
*** 4277,4280 ****
--- 4277,4282 ----
  		      struct symbol_info *si)
  {
+ 	if (c->c_future && c->c_future->ff_nested_scopes)
+ 		c->c_flags |= CO_NESTED;
  	if (ste->ste_type != TYPE_MODULE)
  		c->c_flags |= CO_NEWLOCALS;