Skip to content

REPL wrap Issue when a response ends in a continuation #283

Open
@Kotarski

Description

# We got the continuation prompt - command was incomplete

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions