summaryrefslogtreecommitdiffstats
path: root/Objects/frameobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-07-26 16:14:30 (GMT)
committerGuido van Rossum <guido@python.org>1995-07-26 16:14:30 (GMT)
commitbdd207af79d55d5aa11d00f56313929eb92d1822 (patch)
treeabcb7c17d90d84cdf3857eea884d3ef4c3f55417 /Objects/frameobject.c
parent3fc9d73e08201d8987bc3e0355a2dddc8036a176 (diff)
downloadcpython-bdd207af79d55d5aa11d00f56313929eb92d1822.zip
cpython-bdd207af79d55d5aa11d00f56313929eb92d1822.tar.gz
cpython-bdd207af79d55d5aa11d00f56313929eb92d1822.tar.bz2
better policy regarding NULL locals
Diffstat (limited to 'Objects/frameobject.c')
-rw-r--r--Objects/frameobject.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index b288408..6441855 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -181,11 +181,15 @@ newframeobject(back, code, globals, locals, owner, nvalues, nblocks)
f->f_builtins = builtins;
INCREF(globals);
f->f_globals = globals;
- if ((code->co_flags & (CO_NEWLOCALS|CO_OPTIMIZED)) == CO_NEWLOCALS) {
- locals = newdictobject();
- if (locals == NULL) {
- DECREF(f);
- return NULL;
+ if (code->co_flags & CO_NEWLOCALS) {
+ if (code->co_flags & CO_OPTIMIZED)
+ locals = NULL; /* Let fast_2_locals handle it */
+ else {
+ locals = newdictobject();
+ if (locals == NULL) {
+ DECREF(f);
+ return NULL;
+ }
}
}
else {
@@ -285,10 +289,6 @@ fast_2_locals(f)
int j;
if (f == NULL)
return;
- fast = f->f_fastlocals;
- if (fast == NULL || f->f_code->co_nlocals == 0)
- return;
- map = f->f_code->co_varnames;
locals = f->f_locals;
if (locals == NULL) {
locals = f->f_locals = newdictobject();
@@ -297,6 +297,10 @@ fast_2_locals(f)
return;
}
}
+ fast = f->f_fastlocals;
+ if (fast == NULL || f->f_code->co_nlocals == 0)
+ return;
+ map = f->f_code->co_varnames;
if (!is_dictobject(locals) || !is_listobject(fast) ||
!is_tupleobject(map))
return;