Show More
@@ -139,7 +139,6 b' class CachingCompiler(codeop.Compile):' | |||
|
139 | 139 | def extra_flags(self, flags): |
|
140 | 140 | old_flags = self.flags |
|
141 | 141 | self.flags = self.flags | flags |
|
142 | print('flags', old_flags ,'->', self.flags) | |
|
143 | 142 | try: |
|
144 | 143 | yield |
|
145 | 144 | finally: |
@@ -3202,6 +3202,7 b' class InteractiveShell(SingletonConfigurable):' | |||
|
3202 | 3202 | raise ValueError("Interactivity was %r" % interactivity) |
|
3203 | 3203 | try: |
|
3204 | 3204 | if _async and sys.version_info < (3,8): |
|
3205 | raise ValueError | |
|
3205 | 3206 | # If interactivity is async the semantics of run_code are |
|
3206 | 3207 | # completely different Skip usual machinery. |
|
3207 | 3208 | mod = Module(nodelist, []) |
@@ -3211,18 +3212,26 b' class InteractiveShell(SingletonConfigurable):' | |||
|
3211 | 3212 | if (yield from self.run_code(async_code, result, async_=True)): |
|
3212 | 3213 | return True |
|
3213 | 3214 | else: |
|
3215 | def compare(code): | |
|
3216 | import inspect | |
|
3217 | is_async = (inspect.CO_COROUTINE & code.co_flags == inspect.CO_COROUTINE) | |
|
3218 | print('async=', _async, 'autodetect=', is_async) | |
|
3219 | return is_async | |
|
3214 | 3220 | for i, node in enumerate(to_run_exec): |
|
3215 | 3221 | mod = Module([node], []) |
|
3216 | 3222 | code = compiler(mod, cell_name, "exec") |
|
3223 | compare(code) | |
|
3217 | 3224 | if (yield from self.run_code(code, result)): |
|
3218 | 3225 | return True |
|
3219 | 3226 | |
|
3220 | 3227 | for i, node in enumerate(to_run_interactive): |
|
3221 | 3228 | print('B: interactive, async=', _async, nodelist) |
|
3222 | 3229 | mod = ast.Interactive([node]) |
|
3223 |
with compiler.extra_flags( |
|
|
3230 | with compiler.extra_flags(ast.ast.PyCF_ALLOW_TOP_LEVEL_AWAIT if _async else 0x0): | |
|
3224 | 3231 | code = compiler(mod, cell_name, "single") |
|
3225 | if (yield from self.run_code(code, result, async_=_async)): | |
|
3232 | asy = compare(code) | |
|
3233 | ||
|
3234 | if (yield from self.run_code(code, result, async_=asy)): | |
|
3226 | 3235 | return True |
|
3227 | 3236 | |
|
3228 | 3237 | # Flush softspace |
@@ -3298,7 +3307,7 b' class InteractiveShell(SingletonConfigurable):' | |||
|
3298 | 3307 | code = compile('last_expr', 'fake', "single") |
|
3299 | 3308 | exec(code, {'last_expr': last_expr}) |
|
3300 | 3309 | elif async_ : |
|
3301 |
|
|
|
3310 | yield from eval(code_obj, self.user_global_ns, self.user_ns) | |
|
3302 | 3311 | else: |
|
3303 | 3312 | exec(code_obj, self.user_global_ns, self.user_ns) |
|
3304 | 3313 | finally: |
General Comments 0
You need to be logged in to leave comments.
Login now