diff Python/ceval.c @ 23194:0c8e762a677c 2.1

Backport fixes for two nested scopes bugs. frameobject.c: make sure free and cell vars make it into locals, which makes eval work. bltinmodule.c & ceval.c: make sure a code object with free variables that is passed to exec or eval raises an exception. Also duplicate the current trunk test suite in the 2.1 branch, except for certain necessary changes: different warnings raised by 2.1, need for __future__.
author Jeremy Hylton <jeremy@alum.mit.edu>
date Sat, 20 Apr 2002 18:21:29 +0000
parents 880d3106499b
children
line wrap: on
line diff
--- a/Python/ceval.c	Fri Apr 19 00:11:32 2002 +0000
+++ b/Python/ceval.c	Sat Apr 20 18:21:29 2002 +0000
@@ -3514,6 +3514,11 @@
 	if (PyDict_GetItemString(globals, "__builtins__") == NULL)
 		PyDict_SetItemString(globals, "__builtins__", f->f_builtins);
 	if (PyCode_Check(prog)) {
+		if (PyCode_GetNumFree((PyCodeObject *)prog) > 0) {
+			PyErr_SetString(PyExc_TypeError,
+		"code object passed to exec may not contain free variables");
+			return -1;
+		}
 		v = PyEval_EvalCode((PyCodeObject *) prog, globals, locals);
 	}
 	else if (PyFile_Check(prog)) {