fix globals/locals defaults for eval/execfile

This commit is contained in:
Guido van Rossum 1995-01-10 10:47:05 +00:00
parent 10393b1708
commit 84eaa8396e

View file

@ -384,7 +384,7 @@ builtin_eval(self, args)
object *args; object *args;
{ {
object *cmd; object *cmd;
object *globals = NULL, *locals = NULL; object *globals = None, *locals = None;
char *str; char *str;
if (!newgetargs(args, "O|O!O!:eval", if (!newgetargs(args, "O|O!O!:eval",
@ -392,12 +392,12 @@ builtin_eval(self, args)
&Mappingtype, &globals, &Mappingtype, &globals,
&Mappingtype, &locals)) &Mappingtype, &locals))
return NULL; return NULL;
if (globals == NULL) { if (globals == None) {
globals = getglobals(); globals = getglobals();
if (globals == NULL) if (locals == None)
return NULL; locals = getlocals();
} }
if (locals == NULL) else if (locals == None)
locals = globals; locals = globals;
if (dictlookup(globals, "__builtins__") == NULL) { if (dictlookup(globals, "__builtins__") == NULL) {
if (dictinsert(globals, "__builtins__", getbuiltins()) != 0) if (dictinsert(globals, "__builtins__", getbuiltins()) != 0)
@ -428,7 +428,7 @@ builtin_execfile(self, args)
object *args; object *args;
{ {
char *filename; char *filename;
object *globals = NULL, *locals = NULL; object *globals = None, *locals = None;
object *res; object *res;
FILE* fp; FILE* fp;
char *s; char *s;
@ -439,12 +439,12 @@ builtin_execfile(self, args)
&Mappingtype, &globals, &Mappingtype, &globals,
&Mappingtype, &locals)) &Mappingtype, &locals))
return NULL; return NULL;
if (globals == NULL) { if (globals == None) {
globals = getglobals(); globals = getglobals();
if (globals == NULL) if (locals == None)
return NULL; locals = getlocals();
} }
if (locals == NULL) else if (locals == None)
locals = globals; locals = globals;
if (dictlookup(globals, "__builtins__") == NULL) { if (dictlookup(globals, "__builtins__") == NULL) {
if (dictinsert(globals, "__builtins__", getbuiltins()) != 0) if (dictinsert(globals, "__builtins__", getbuiltins()) != 0)