Skip to content

Commit 3bf3998

Browse files
Fix last commit: allow await in assignment expressions when the REPL itself is not running async.
1 parent 70dd3bd commit 3bf3998

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ptpython/repl.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,10 @@ def eval(self, line: str) -> object:
239239
# above, then `sys.exc_info()` would not report the right error.
240240
# See issue: https://github.com/prompt-toolkit/ptpython/issues/435
241241
code = self._compile_with_flags(line, "exec")
242-
exec(code, self.get_globals(), self.get_locals())
242+
result = eval(code, self.get_globals(), self.get_locals())
243+
244+
if _has_coroutine_flag(code):
245+
result = asyncio.get_event_loop().run_until_complete(result)
243246

244247
return None
245248

0 commit comments

Comments
 (0)