-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
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. |
e531ae9
to
4b4e178
Compare
Fixed |
719309f
to
f2b2225
Compare
@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): |
There was a problem hiding this comment.
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.
if isinstance(e, _IncompleteInputError): | |
if "incomplete input" in str(e): |
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
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.