Fix for SF bug [ #492403 ] exec() segfaults on closure's func_code

Based on the patch from Danny Yoo.  The fix is in exec_statement() in
ceval.c.

There are also changes to introduce use of PyCode_GetNumFree() in
several places.
This commit is contained in:
Jeremy Hylton 2001-12-13 19:51:56 +00:00
parent 3095a4c228
commit 733c8935f9
3 changed files with 10 additions and 5 deletions

View file

@ -497,7 +497,7 @@ builtin_eval(PyObject *self, PyObject *args)
}
if (PyCode_Check(cmd)) {
if (PyTuple_GET_SIZE(((PyCodeObject *)cmd)->co_freevars) > 0) {
if (PyCode_GetNumFree((PyCodeObject *)cmd) > 0) {
PyErr_SetString(PyExc_TypeError,
"code object passed to eval() may not contain free variables");
return NULL;