summaryrefslogtreecommitdiffstats
path: root/Lib/codeop.py
diff options
context:
space:
mode:
authorWulian <xiguawulian@gmail.com>2024-10-14 13:53:50 (GMT)
committerGitHub <noreply@github.com>2024-10-14 13:53:50 (GMT)
commit6a08a753b702ac63c9b6ac58dd204d1fe9662e9d (patch)
tree9942fe005e3c556672b05d3d01905ac083027838 /Lib/codeop.py
parent5f4e5b598cab86d5fd5727d423c9728221889ed0 (diff)
downloadcpython-6a08a753b702ac63c9b6ac58dd204d1fe9662e9d.zip
cpython-6a08a753b702ac63c9b6ac58dd204d1fe9662e9d.tar.gz
cpython-6a08a753b702ac63c9b6ac58dd204d1fe9662e9d.tar.bz2
gh-124960: Fixed `barry_as_FLUFL` future flag does not work in new REPL (#124999)
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com> Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/codeop.py')
-rw-r--r--Lib/codeop.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/codeop.py b/Lib/codeop.py
index a0276b5..adf000b 100644
--- a/Lib/codeop.py
+++ b/Lib/codeop.py
@@ -44,6 +44,7 @@ __all__ = ["compile_command", "Compile", "CommandCompiler"]
# Caveat emptor: These flags are undocumented on purpose and depending
# on their effect outside the standard library is **unsupported**.
PyCF_DONT_IMPLY_DEDENT = 0x200
+PyCF_ONLY_AST = 0x400
PyCF_ALLOW_INCOMPLETE_INPUT = 0x4000
def _maybe_compile(compiler, source, filename, symbol):
@@ -109,12 +110,14 @@ class Compile:
def __init__(self):
self.flags = PyCF_DONT_IMPLY_DEDENT | PyCF_ALLOW_INCOMPLETE_INPUT
- def __call__(self, source, filename, symbol, **kwargs):
- flags = self.flags
+ def __call__(self, source, filename, symbol, flags=0, **kwargs):
+ flags |= self.flags
if kwargs.get('incomplete_input', True) is False:
flags &= ~PyCF_DONT_IMPLY_DEDENT
flags &= ~PyCF_ALLOW_INCOMPLETE_INPUT
codeob = compile(source, filename, symbol, flags, True)
+ if flags & PyCF_ONLY_AST:
+ return codeob # this is an ast.Module in this case
for feature in _features:
if codeob.co_flags & feature.compiler_flag:
self.flags |= feature.compiler_flag