Skip to content

Commit 87bb1e3

Browse files
derekbrokeitjonathanslenders
authored andcommitted
fix embed coroutine for asyncio repl
- maintains compatibility with py2 syntax
1 parent f9ed1d5 commit 87bb1e3

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

ptpython/repl.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,20 @@ def get_locals():
337337
if return_asyncio_coroutine: # XXX
338338
def coroutine():
339339
with patch_context:
340-
for future in app.run_async():
341-
yield future
340+
while True:
341+
iterator = iter(app.run_async().to_asyncio_future())
342+
try:
343+
while True:
344+
yield next(iterator)
345+
except StopIteration as exc:
346+
if exc.args:
347+
text = exc.args[0]
348+
else:
349+
text = None
350+
try:
351+
repl._process_text(text)
352+
except EOFError:
353+
return
342354
return coroutine()
343355
else:
344356
with patch_context:

0 commit comments

Comments
 (0)