Mercurial > cpython-lru_cache-weakref
diff Python/compile.c @ 21398:de125792bfaa legacy-trunk
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.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Thu, 13 Dec 2001 19:51:56 +0000 |
| parents | 485422900ef0 |
| children | 4f54e9a2976e 3ba0f1b20320 |
line wrap: on
line diff
--- a/Python/compile.c Thu Dec 13 19:47:51 2001 +0000 +++ b/Python/compile.c Thu Dec 13 19:51:56 2001 +0000 @@ -2273,7 +2273,7 @@ static int com_make_closure(struct compiling *c, PyCodeObject *co) { - int i, free = PyTuple_GET_SIZE(co->co_freevars); + int i, free = PyCode_GetNumFree(co); if (free == 0) return 0; for (i = 0; i < free; ++i) { @@ -2333,7 +2333,7 @@ com_push(c, 1); if (closure) { com_addoparg(c, MAKE_CLOSURE, ndefs); - com_pop(c, PyTuple_GET_SIZE(co->co_freevars)); + com_pop(c, PyCode_GetNumFree(co)); } else com_addoparg(c, MAKE_FUNCTION, ndefs); Py_DECREF(co); @@ -3590,7 +3590,7 @@ com_push(c, 1); if (closure) { com_addoparg(c, MAKE_CLOSURE, 0); - com_pop(c, PyTuple_GET_SIZE(co->co_freevars)); + com_pop(c, PyCode_GetNumFree(co)); } else com_addoparg(c, MAKE_FUNCTION, 0); com_addoparg(c, CALL_FUNCTION, 0);
