Show More
@@ -150,9 +150,11 b' def _should_be_async(cell: str) -> bool:' | |||
|
150 | 150 | level, it will be seen as async. This is a know limitation. |
|
151 | 151 | """ |
|
152 | 152 | if sys.version_info > (3, 8): |
|
153 | try: | |
|
153 | 154 | code = compile(cell, "<>", "exec", flags=getattr(ast,'PyCF_ALLOW_TOP_LEVEL_AWAIT', 0x0)) |
|
154 | 155 | return inspect.CO_COROUTINE & code.co_flags == inspect.CO_COROUTINE |
|
155 | ||
|
156 | except SyntaxError: | |
|
157 | return False | |
|
156 | 158 | try: |
|
157 | 159 | # we can't limit ourself to ast.parse, as it __accepts__ to parse on |
|
158 | 160 | # 3.7+, but just does not _compile_ |
@@ -137,12 +137,17 b' class CachingCompiler(codeop.Compile):' | |||
|
137 | 137 | |
|
138 | 138 | @contextmanager |
|
139 | 139 | def extra_flags(self, flags): |
|
140 | old_flags = self.flags | |
|
140 | ## bits that we'll set to 1 | |
|
141 | turn_on_bits = ~self.flags & flags | |
|
142 | ||
|
143 | ||
|
141 | 144 | self.flags = self.flags | flags |
|
142 | 145 | try: |
|
143 | 146 | yield |
|
144 | 147 | finally: |
|
145 | self.flags = old_flags | |
|
148 | # turn off only the bits we turned on so that something like | |
|
149 | # __future__ that set flags stays. | |
|
150 | self.flags &= ~turn_on_bits | |
|
146 | 151 | |
|
147 | 152 | |
|
148 | 153 | def check_linecache_ipython(*args): |
General Comments 0
You need to be logged in to leave comments.
Login now