aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/codeop.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/tools/python3/src/Lib/codeop.py
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
downloadydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Lib/codeop.py')
-rw-r--r--contrib/tools/python3/src/Lib/codeop.py54
1 files changed, 27 insertions, 27 deletions
diff --git a/contrib/tools/python3/src/Lib/codeop.py b/contrib/tools/python3/src/Lib/codeop.py
index c58f4038fa0..4c10470aee7 100644
--- a/contrib/tools/python3/src/Lib/codeop.py
+++ b/contrib/tools/python3/src/Lib/codeop.py
@@ -57,7 +57,7 @@ Compile():
"""
import __future__
-import warnings
+import warnings
_features = [getattr(__future__, fname)
for fname in __future__.all_feature_names]
@@ -81,31 +81,31 @@ def _maybe_compile(compiler, source, filename, symbol):
try:
code = compiler(source, filename, symbol)
- except SyntaxError:
+ except SyntaxError:
pass
- # Catch syntax warnings after the first compile
- # to emit warnings (SyntaxWarning, DeprecationWarning) at most once.
- with warnings.catch_warnings():
- warnings.simplefilter("error")
-
- try:
- code1 = compiler(source + "\n", filename, symbol)
- except SyntaxError as e:
- err1 = e
-
- try:
- code2 = compiler(source + "\n\n", filename, symbol)
- except SyntaxError as e:
- err2 = e
-
- try:
- if code:
- return code
- if not code1 and repr(err1) == repr(err2):
- raise err1
- finally:
- err1 = err2 = None
+ # Catch syntax warnings after the first compile
+ # to emit warnings (SyntaxWarning, DeprecationWarning) at most once.
+ with warnings.catch_warnings():
+ warnings.simplefilter("error")
+
+ try:
+ code1 = compiler(source + "\n", filename, symbol)
+ except SyntaxError as e:
+ err1 = e
+
+ try:
+ code2 = compiler(source + "\n\n", filename, symbol)
+ except SyntaxError as e:
+ err2 = e
+
+ try:
+ if code:
+ return code
+ if not code1 and repr(err1) == repr(err2):
+ raise err1
+ finally:
+ err1 = err2 = None
def _compile(source, filename, symbol):
return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT)
@@ -118,8 +118,8 @@ def compile_command(source, filename="<input>", symbol="single"):
source -- the source string; may contain \n characters
filename -- optional filename from which source was read; default
"<input>"
- symbol -- optional grammar start symbol; "single" (default), "exec"
- or "eval"
+ symbol -- optional grammar start symbol; "single" (default), "exec"
+ or "eval"
Return value / exceptions raised:
@@ -140,7 +140,7 @@ class Compile:
self.flags = PyCF_DONT_IMPLY_DEDENT
def __call__(self, source, filename, symbol):
- codeob = compile(source, filename, symbol, self.flags, True)
+ codeob = compile(source, filename, symbol, self.flags, True)
for feature in _features:
if codeob.co_flags & feature.compiler_flag:
self.flags |= feature.compiler_flag