mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Useful future statement support for the interactive interpreter
(Also remove warning about module-level global decl, because we can't distinguish from code passed to exec.) Define PyCompilerFlags type contains a single element, cf_nested_scopes, that is true if a nested scopes future statement has been entered at the interactive prompt. New API functions: PyNode_CompileFlags() PyRun_InteractiveOneFlags() -- same as their non Flags counterparts except that the take an optional PyCompilerFlags pointer compile.c: In jcompile() use PyCompilerFlags argument. If cf_nested_scopes is true, compile code with nested scopes. If it is false, but the code has a valid future nested scopes statement, set it to true. pythonrun.c: Create a new PyCompilerFlags object in PyRun_InteractiveLoop() and thread it through to PyRun_InteractiveOneFlags().
This commit is contained in:
parent
0f6b3832b9
commit
9f324e964e
4 changed files with 59 additions and 26 deletions
|
@ -57,6 +57,8 @@ typedef struct {
|
|||
} PyFutureFeatures;
|
||||
|
||||
DL_IMPORT(PyFutureFeatures *) PyNode_Future(struct _node *, char *);
|
||||
DL_IMPORT(PyCodeObject *) PyNode_CompileFlags(struct _node *, char *,
|
||||
PyCompilerFlags *);
|
||||
|
||||
#define NESTED_SCOPES_DEFAULT 0
|
||||
#define FUTURE_NESTED_SCOPES "nested_scopes"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue