mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
3095a4c228
commit
733c8935f9
3 changed files with 10 additions and 5 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue