Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Kotarski opened this issue Nov 4, 2024 · 0 comments
Open

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

Kotarski opened this issue Nov 4, 2024 · 0 comments

Comments

@Kotarski
Copy link

Kotarski commented Nov 4, 2024

# 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant