summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-03-22 02:47:58 +0000
committerJeremy Hylton <jeremy@alum.mit.edu>2001-03-22 02:47:58 +0000
commitbc32024769eecd3c2251e00850e6a5c003aa9253 (patch)
treeac22247a92d89b1952de8defcb42c17f07e24a7b /Modules
parent061d106a0f56c5b4171ad8c56ecfaa6cefb27385 (diff)
downloadcpython-git-bc32024769eecd3c2251e00850e6a5c003aa9253.tar.gz
Extend support for from __future__ import nested_scopes
If a module has a future statement enabling nested scopes, they are also enable for the exec statement and the functions compile() and execfile() if they occur in the module. If Python is run with the -i option, which enters interactive mode after executing a script, and the script it runs enables nested scopes, they are also enabled in interactive mode. XXX The use of -i with -c "from __future__ import nested_scopes" is not supported. What's the point? To support these changes, many function variants have been added to pythonrun.c. All the variants names end with Flags and they take an extra PyCompilerFlags * argument. It is possible that this complexity will be eliminated in a future version of the interpreter in which nested scopes are not optional.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/main.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 03dff1888f..b4566c94af 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -99,6 +99,7 @@ Py_Main(int argc, char **argv)
int stdin_is_interactive = 0;
int help = 0;
int version = 0;
+ PyCompilerFlags cf;
orig_argc = argc; /* For Py_GetArgcArgv() */
orig_argv = argv;
@@ -293,6 +294,8 @@ Py_Main(int argc, char **argv)
Py_DECREF(v);
}
+ cf.cf_nested_scopes = 0;
+
if (command) {
sts = PyRun_SimpleString(command) != 0;
free(command);
@@ -309,15 +312,17 @@ Py_Main(int argc, char **argv)
}
}
}
- sts = PyRun_AnyFileEx(
+ /* XXX */
+ sts = PyRun_AnyFileExFlags(
fp,
filename == NULL ? "<stdin>" : filename,
- filename != NULL) != 0;
+ filename != NULL, &cf) != 0;
}
if (inspect && stdin_is_interactive &&
(filename != NULL || command != NULL))
- sts = PyRun_AnyFile(stdin, "<stdin>") != 0;
+ /* XXX */
+ sts = PyRun_AnyFileFlags(stdin, "<stdin>", &cf) != 0;
Py_Finalize();
#ifdef RISCOS