Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.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 | 2edaa8e9f381 |
| children | 5dbc79ee0885 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Fri Apr 19 00:11:32 2002 +0000 +++ b/Python/bltinmodule.c Sat Apr 20 18:21:29 2002 +0000 @@ -756,8 +756,14 @@ PyEval_GetBuiltins()) != 0) return NULL; } - if (PyCode_Check(cmd)) + if (PyCode_Check(cmd)) { + if (PyCode_GetNumFree((PyCodeObject *)cmd) > 0) { + PyErr_SetString(PyExc_TypeError, + "code object passed to eval() may not contain free variables"); + return NULL; + } return PyEval_EvalCode((PyCodeObject *) cmd, globals, locals); + } if (!PyString_Check(cmd) && !PyUnicode_Check(cmd)) { PyErr_SetString(PyExc_TypeError,
