🌐 AI搜索 & 代理 主页
Skip to content

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 original 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