Skip to content

Commit 08a163a

Browse files
authored
Merge pull request #606 from meeseeksmachine/auto-backport-of-pr-605-on-5.5.x
Backport PR #605 on branch 5.5.x (Fix Handling of shell.should_run_async)
2 parents b53143f + 5a05610 commit 08a163a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ipykernel/ipkernel.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,16 @@ def run_cell(*args, **kwargs):
278278
# default case: runner is asyncio and asyncio is already running
279279
# TODO: this should check every case for "are we inside the runner",
280280
# not just asyncio
281+
preprocessing_exc_tuple = None
282+
try:
283+
transformed_cell = self.shell.transform_cell(code)
284+
except Exception:
285+
transformed_cell = code
286+
preprocessing_exc_tuple = sys.exc_info()
287+
281288
if (
282289
_asyncio_runner
283-
and should_run_async(code)
290+
and should_run_async(code, transformed_cell=transformed_cell, preprocessing_exc_tuple=preprocessing_exc_tuple)
284291
and shell.loop_runner is _asyncio_runner
285292
and asyncio.get_event_loop().is_running()
286293
):
@@ -372,14 +379,14 @@ def do_complete(self, code, cursor_pos):
372379

373380
def _experimental_do_complete(self, code, cursor_pos):
374381
"""
375-
Experimental completions from IPython, using Jedi.
382+
Experimental completions from IPython, using Jedi.
376383
"""
377384
if cursor_pos is None:
378385
cursor_pos = len(code)
379386
with _provisionalcompleter():
380387
raw_completions = self.shell.Completer.completions(code, cursor_pos)
381388
completions = list(_rectify_completions(code, raw_completions))
382-
389+
383390
comps = []
384391
for comp in completions:
385392
comps.append(dict(

0 commit comments

Comments
 (0)