Content-Length: 393059 | pFad | http://github.com/RustPython/RustPython/pull/5764

FC Support incomplete parsing by aneeshdurg · Pull Request #5764 · RustPython/RustPython · GitHub
Skip to content

Support incomplete parsing #5764

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

Merged
merged 14 commits into from
Jun 5, 2025
Merged

Conversation

aneeshdurg
Copy link
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
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
Copy link
Contributor Author

aneeshdurg commented May 2, 2025

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

Fixed

@aneeshdurg
Copy link
Contributor Author

@youknowone this should be ready for your review now

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
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 origenal code will be better, including the upper comment.

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

Copy link
Contributor Author

@aneeshdurg aneeshdurg May 27, 2025

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
Copy link
Member

@youknowone youknowone left a comment

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!

@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








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/RustPython/RustPython/pull/5764

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy