Skip to content

Support incomplete parsing#5764

Merged
youknowone merged 14 commits into
RustPython:mainfrom
aneeshdurg:incomplete_error
Jun 5, 2025
Merged

Support incomplete parsing#5764
youknowone merged 14 commits into
RustPython:mainfrom
aneeshdurg:incomplete_error

Conversation

@aneeshdurg

Copy link
Copy Markdown
Contributor

This PR adds support for incomplete parsing both in the native REPL and in the stdin REPL (in particular multiline input support is expanded for to allow more cases such as multiline strings). The implementation adds compatibility for cpython's PY_CF_ALLOW_INCOMPLETE_INPUT compile flag and adds a new exception type similar to python 3.14.

@aneeshdurg

Copy link
Copy Markdown
Contributor Author

This brings the project a step closer to having a single REPL implementation! There's still some deficiencies in the stdlib parser for parsing blocks for functions/classes though.

@aneeshdurg

aneeshdurg commented May 2, 2025

Copy link
Copy Markdown
Contributor Author

It seems like the test_pickle* failures might be unrelated to this PR?

Fixed

@aneeshdurg

Copy link
Copy Markdown
Contributor Author

@youknowone this should be ready for your review now

Comment thread Lib/codeop.py Outdated
if source.endswith(":") and "expected an indented block" in strerr:
return None
elif "incomplete input" in str(e):
if isinstance(e, _IncompleteInputError):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? Then partially reverting #5743 to the original code will be better, including the upper comment.

Suggested change
if isinstance(e, _IncompleteInputError):
if "incomplete input" in str(e):

@aneeshdurg aneeshdurg May 27, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't work, since _IncompleteInputError doesn't necessarily have that string in the error. I've removed the comment and changed this block to just match python 3.15's implementation at least.

@aneeshdurg aneeshdurg requested a review from youknowone June 2, 2025 13:49

@youknowone youknowone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thank you so much!

Comment thread Lib/test/test_baseexception.py Outdated
@youknowone youknowone merged commit 323ea3b into RustPython:main Jun 5, 2025
10 of 11 checks passed
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

Successfully merging this pull request may close these issues.

2 participants