metakernel
metakernel copied to clipboard
REPL wrap Issue when a response ends in a continuation
https://github.com/Calysto/metakernel/blob/2de5d373c41d7b4af3879c2764fdbe904cc12378/metakernel/replwrap.py#L243
I've been using this to wrap a python interpreter and have come across the issue that the run_command code doesn't distinguish between a hard continuation where a statement is missing a body e.g.
if true:
and a soft continuation where a statement could contain more in its body:
if true:
print("hi")
This results in the value error being raised each time a nested statement is used.
To solve the issue in Python the code can be modified to:
if self._expect_prompt(timeout=timeout) == 1:
# Try and resolve the continuation
self.sendline("")
if self._expect_prompt(timeout=timeout) == 1:
# We got the continuation prompt - command was incomplete
self.interrupt(continuation=True)
raise ValueError("Continuation prompt found - input was incomplete:\n" + command)
Perhaps this could be added as an option on the class?