Kaydet (Commit) 84eaa839 authored tarafından Guido van Rossum's avatar Guido van Rossum

fix globals/locals defaults for eval/execfile

üst 10393b17
...@@ -384,7 +384,7 @@ builtin_eval(self, args) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment