diff options
author | shadchin <shadchin@yandex-team.com> | 2023-12-13 02:43:57 +0300 |
---|---|---|
committer | shadchin <shadchin@yandex-team.com> | 2023-12-13 03:08:48 +0300 |
commit | 5b48aabc614c6d407f885f3b228dc484ad4c5ba9 (patch) | |
tree | 602eb5cc5d85bf730c1de1fa50a13c2ee552830d /contrib/tools/python3/src/Lib/codeop.py | |
parent | 35d7049b38602e8cbfcd3f96257329a1abce947e (diff) | |
download | ydb-5b48aabc614c6d407f885f3b228dc484ad4c5ba9.tar.gz |
Update Python 3 to 3.11.7
Diffstat (limited to 'contrib/tools/python3/src/Lib/codeop.py')
-rw-r--r-- | contrib/tools/python3/src/Lib/codeop.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/contrib/tools/python3/src/Lib/codeop.py b/contrib/tools/python3/src/Lib/codeop.py index 2213b69f231..e64911ee5ad 100644 --- a/contrib/tools/python3/src/Lib/codeop.py +++ b/contrib/tools/python3/src/Lib/codeop.py @@ -70,8 +70,7 @@ def _maybe_compile(compiler, source, filename, symbol): return None # fallthrough - return compiler(source, filename, symbol) - + return compiler(source, filename, symbol, incomplete_input=False) def _is_syntax_error(err1, err2): rep1 = repr(err1) @@ -82,8 +81,12 @@ def _is_syntax_error(err1, err2): return True return False -def _compile(source, filename, symbol): - return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT | PyCF_ALLOW_INCOMPLETE_INPUT) +def _compile(source, filename, symbol, incomplete_input=True): + flags = 0 + if incomplete_input: + flags |= PyCF_ALLOW_INCOMPLETE_INPUT + flags |= PyCF_DONT_IMPLY_DEDENT + return compile(source, filename, symbol, flags) def compile_command(source, filename="<input>", symbol="single"): r"""Compile a command and determine whether it is incomplete. @@ -114,8 +117,12 @@ class Compile: def __init__(self): self.flags = PyCF_DONT_IMPLY_DEDENT | PyCF_ALLOW_INCOMPLETE_INPUT - def __call__(self, source, filename, symbol): - codeob = compile(source, filename, symbol, self.flags, True) + def __call__(self, source, filename, symbol, **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) for feature in _features: if codeob.co_flags & feature.compiler_flag: self.flags |= feature.compiler_flag |