##// END OF EJS Templates
Fix `compile()` invocation
Artur Svistunov -
Show More
@@ -12,7 +12,7 b' deprecated in 7.0.'
12 12
13 13 import ast
14 14 import sys
15 from codeop import CommandCompiler
15 from codeop import CommandCompiler, Compile
16 16 import re
17 17 import tokenize
18 18 from typing import List, Tuple, Optional, Any
@@ -777,14 +777,18 b' def find_last_indent(lines):'
777 777 return len(m.group(0).replace('\t', ' '*4))
778 778
779 779
780 class MaybeAsyncCompile(Compile):
781 def __init__(self, extra_flags=0):
782 super().__init__()
783 self.flags |= extra_flags
784
785 __call__ = compile
786
787
780 788 class MaybeAsyncCommandCompiler(CommandCompiler):
781 789 def __init__(self, extra_flags=0):
782 self.compiler = self._compiler
783 self.extra_flags = extra_flags
790 self.compiler = MaybeAsyncCompile(extra_flags=extra_flags)
784 791
785 def _compiler(self, source, filename, symbol, flags, feature):
786 flags |= self.extra_flags
787 return compile(source, filename, symbol, flags, feature)
788 792
789 793 if (sys.version_info.major, sys.version_info.minor) >= (3, 8):
790 794 _extra_flags = ast.PyCF_ALLOW_TOP_LEVEL_AWAIT
General Comments 0
You need to be logged in to leave comments. Login now