summaryrefslogtreecommitdiffstats
path: root/Objects/frameobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-01-10 10:39:16 (GMT)
committerGuido van Rossum <guido@python.org>1995-01-10 10:39:16 (GMT)
commitc11348287187606efd7a0dce76269440ca170f8e (patch)
tree40cb8f6c0a8f70697f2d796248ee700e377416b8 /Objects/frameobject.c
parentbe9f212f7e70c650e3717f2bbe55bdc22b9c8e9c (diff)
downloadcpython-c11348287187606efd7a0dce76269440ca170f8e.zip
cpython-c11348287187606efd7a0dce76269440ca170f8e.tar.gz
cpython-c11348287187606efd7a0dce76269440ca170f8e.tar.bz2
add builtins handling and restricted flag
Diffstat (limited to 'Objects/frameobject.c')
-rw-r--r--Objects/frameobject.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 29cb171..52b4e52 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -30,12 +30,14 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "frameobject.h"
#include "opcode.h"
#include "structmember.h"
+#include "bltinmodule.h"
#define OFF(x) offsetof(frameobject, x)
static struct memberlist frame_memberlist[] = {
{"f_back", T_OBJECT, OFF(f_back), RO},
{"f_code", T_OBJECT, OFF(f_code), RO},
+ {"f_builtins", T_OBJECT, OFF(f_builtins),RO},
{"f_globals", T_OBJECT, OFF(f_globals), RO},
{"f_locals", T_OBJECT, OFF(f_locals), RO},
{"f_owner", T_OBJECT, OFF(f_owner), RO},
@@ -45,6 +47,7 @@ static struct memberlist frame_memberlist[] = {
{"f_localmap", T_OBJECT, OFF(f_localmap),RO},
{"f_lasti", T_INT, OFF(f_lasti), RO},
{"f_lineno", T_INT, OFF(f_lineno), RO},
+ {"f_restricted",T_INT, OFF(f_restricted),RO},
{"f_trace", T_OBJECT, OFF(f_trace)},
{NULL} /* Sentinel */
};
@@ -97,6 +100,7 @@ frame_dealloc(f)
{
XDECREF(f->f_back);
XDECREF(f->f_code);
+ XDECREF(f->f_builtins);
XDECREF(f->f_globals);
XDECREF(f->f_locals);
XDECREF(f->f_owner);
@@ -135,6 +139,7 @@ newframeobject(back, code, globals, locals, owner, nvalues, nblocks)
int nblocks;
{
frameobject *f;
+ object *builtins;
if ((back != NULL && !is_frameobject(back)) ||
code == NULL || !is_codeobject(code) ||
globals == NULL || !is_dictobject(globals) ||
@@ -143,6 +148,11 @@ newframeobject(back, code, globals, locals, owner, nvalues, nblocks)
err_badcall();
return NULL;
}
+ builtins = dictlookup(globals, "__builtins__");
+ if (builtins == NULL || !is_mappingobject(builtins)) {
+ err_setstr(TypeError, "bad __builtins__ dictionary");
+ return NULL;
+ }
if (free_list == NULL) {
f = NEWOBJ(frameobject, &Frametype);
f->f_nvalues = f->f_nblocks = 0;
@@ -156,11 +166,12 @@ newframeobject(back, code, globals, locals, owner, nvalues, nblocks)
NEWREF(f);
}
if (f != NULL) {
- if (back)
- INCREF(back);
+ XINCREF(back);
f->f_back = back;
INCREF(code);
f->f_code = code;
+ XINCREF(builtins);
+ f->f_builtins = builtins;
INCREF(globals);
f->f_globals = globals;
INCREF(locals);
@@ -182,6 +193,7 @@ newframeobject(back, code, globals, locals, owner, nvalues, nblocks)
f->f_iblock = 0;
f->f_lasti = 0;
f->f_lineno = -1;
+ f->f_restricted = (builtins != getbuiltindict());
f->f_trace = NULL;
if (f->f_valuestack == NULL || f->f_blockstack == NULL) {
err_nomem();