summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-12-13 19:51:56 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-12-13 19:51:56 (GMT)
commit733c8935f9dfd1be70c472649eb845ea22bbc878 (patch)
tree6febaf1b3d319c55fd8fc5b8789cc3ca4d8fab30 /Python/compile.c
parent3095a4c2289b3155b2dc1bcf7284911dee0afe7d (diff)
downloadcpython-733c8935f9dfd1be70c472649eb845ea22bbc878.zip
cpython-733c8935f9dfd1be70c472649eb845ea22bbc878.tar.gz
cpython-733c8935f9dfd1be70c472649eb845ea22bbc878.tar.bz2
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.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Python/compile.c b/Python/compile.c
index d76769c..4421284 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -2273,7 +2273,7 @@ com_and_test(struct compiling *c, node *n)
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_test(struct compiling *c, node *n)
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_classdef(struct compiling *c, node *n)
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);