##// END OF EJS Templates
workign async with
Matthias Bussonnier -
Show More
@@ -13,6 +13,7 b' Python semantics.'
13
13
14 import ast
14 import ast
15 import sys
15 import sys
16 import inspect
16 from textwrap import dedent, indent
17 from textwrap import dedent, indent
17
18
18
19
@@ -98,6 +99,8 b' class _AsyncSyntaxErrorVisitor(ast.NodeVisitor):'
98 is erroneously allowed (e.g. yield or return at the top level)
99 is erroneously allowed (e.g. yield or return at the top level)
99 """
100 """
100 def __init__(self):
101 def __init__(self):
102 if sys.version_info >= (3,8):
103 raise ValueError('DEPRECATED in Python 3.8+')
101 self.depth = 0
104 self.depth = 0
102 super().__init__()
105 super().__init__()
103
106
@@ -150,9 +153,11 b' def _should_be_async(cell: str) -> bool:'
150 try:
153 try:
151 # we can't limit ourself to ast.parse, as it __accepts__ to parse on
154 # we can't limit ourself to ast.parse, as it __accepts__ to parse on
152 # 3.7+, but just does not _compile_
155 # 3.7+, but just does not _compile_
153 compile(cell, "<>", "exec")
156 code = compile(cell, "<>", "exec", flags=ast.PyCF_ALLOW_TOP_LEVEL_AWAIT)
154 return False
157 return inspect.CO_COROUTINE & code.co_flags == inspect.CO_COROUTINE
155 except SyntaxError:
158 except SyntaxError:
159 #if sys.version_info > (3, 8):
160 # raise
156 try:
161 try:
157 parse_tree = _async_parse_cell(cell)
162 parse_tree = _async_parse_cell(cell)
158
163
General Comments 0
You need to be logged in to leave comments. Login now