Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b7f3cd

Browse files
Use mappinglookup instead of dictlookup for looking up __builtin__.
1 parent f9adf48 commit 5b7f3cd

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Objects/frameobject.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ newframeobject(back, code, globals, locals, owner, nvalues, nblocks)
138138
int nvalues;
139139
int nblocks;
140140
{
141+
static object *builtin_object;
141142
frameobject *f;
142143
object *builtins;
144+
if (builtin_object == NULL) {
145+
builtin_object = newstringobject("__builtins__");
146+
if (builtin_object == NULL)
147+
return NULL;
148+
}
143149
if ((back != NULL && !is_frameobject(back)) ||
144150
code == NULL || !is_codeobject(code) ||
145151
globals == NULL || !is_dictobject(globals) ||
@@ -148,7 +154,7 @@ newframeobject(back, code, globals, locals, owner, nvalues, nblocks)
148154
err_badcall();
149155
return NULL;
150156
}
151-
builtins = dictlookup(globals, "__builtins__");
157+
builtins = mappinglookup(globals, builtin_object);
152158
if (builtins != NULL && is_moduleobject(builtins))
153159
builtins = getmoduledict(builtins);
154160
if (builtins == NULL || !is_mappingobject(builtins)) {

0 commit comments

Comments
 (0)