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