mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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.
This commit is contained in:
parent
061d106a0f
commit
bc32024769
5 changed files with 133 additions and 19 deletions
|
@ -26,12 +26,17 @@ DL_IMPORT(void) Py_EndInterpreter(PyThreadState *);
|
|||
DL_IMPORT(int) PyRun_AnyFile(FILE *, char *);
|
||||
DL_IMPORT(int) PyRun_AnyFileEx(FILE *, char *, int);
|
||||
|
||||
DL_IMPORT(int) PyRun_AnyFileFlags(FILE *, char *, PyCompilerFlags *);
|
||||
DL_IMPORT(int) PyRun_AnyFileExFlags(FILE *, char *, int, PyCompilerFlags *);
|
||||
|
||||
DL_IMPORT(int) PyRun_SimpleString(char *);
|
||||
DL_IMPORT(int) PyRun_SimpleFile(FILE *, char *);
|
||||
DL_IMPORT(int) PyRun_SimpleFileEx(FILE *, char *, int);
|
||||
DL_IMPORT(int) PyRun_SimpleFileExFlags(FILE *, char *, int, PyCompilerFlags *);
|
||||
DL_IMPORT(int) PyRun_InteractiveOne(FILE *, char *);
|
||||
DL_IMPORT(int) PyRun_InteractiveOneFlags(FILE *, char *, PyCompilerFlags *);
|
||||
DL_IMPORT(int) PyRun_InteractiveLoop(FILE *, char *);
|
||||
DL_IMPORT(int) PyRun_InteractiveLoopFlags(FILE *, char *, PyCompilerFlags *);
|
||||
|
||||
DL_IMPORT(struct _node *) PyParser_SimpleParseString(char *, int);
|
||||
DL_IMPORT(struct _node *) PyParser_SimpleParseFile(FILE *, char *, int);
|
||||
|
@ -40,8 +45,16 @@ DL_IMPORT(PyObject *) PyRun_String(char *, int, PyObject *, PyObject *);
|
|||
DL_IMPORT(PyObject *) PyRun_File(FILE *, char *, int, PyObject *, PyObject *);
|
||||
DL_IMPORT(PyObject *) PyRun_FileEx(FILE *, char *, int,
|
||||
PyObject *, PyObject *, int);
|
||||
DL_IMPORT(PyObject *) PyRun_StringFlags(char *, int, PyObject *, PyObject *,
|
||||
PyCompilerFlags *);
|
||||
DL_IMPORT(PyObject *) PyRun_FileFlags(FILE *, char *, int, PyObject *,
|
||||
PyObject *, PyCompilerFlags *);
|
||||
DL_IMPORT(PyObject *) PyRun_FileExFlags(FILE *, char *, int, PyObject *,
|
||||
PyObject *, int, PyCompilerFlags *);
|
||||
|
||||
DL_IMPORT(PyObject *) Py_CompileString(char *, char *, int);
|
||||
DL_IMPORT(PyObject *) Py_CompileStringFlags(char *, char *, int,
|
||||
PyCompilerFlags *);
|
||||
DL_IMPORT(struct symtable *) Py_SymtableString(char *, char *, int);
|
||||
|
||||
DL_IMPORT(void) PyErr_Print(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue