Skip to content

bpo-42864: Improve error messages regarding unclosed parentheses #24161

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 5 commits into from
Jan 19, 2021

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Jan 8, 2021

https://bugs.python.org/issue42864

With this PR:

❯ cat lel.py
( 1+2
❯ ./python lel.py
  File "/home/pablogsal/github/python/master/lel.py", line 1
    ( 1+2
    ^
SyntaxError: '(' was never closed
~/github/python/master parens*
❯ cat ../a.py
x = {
~/github/python/master parens*
❯ ./python ../a.py
  File "/home/pablogsal/github/python/master/../a.py", line 1
    x = {
        ^
SyntaxError: '{' was never closed

@pablogsal
Copy link
Member Author

pablogsal commented Jan 8, 2021

I opened this as a draft to evaluate the idea. This probably needs #24140 to be fixed first for the tests to pass

@tirkarthi
Copy link
Member

cc: @asottile

@pablogsal pablogsal force-pushed the parens branch 5 times, most recently from 823ba3e to 83572fc Compare January 14, 2021 22:47
@pablogsal
Copy link
Member Author

@lysnikolaou Do you mind taking a look at this when you have some time? I hope we can find some way to make this work 🤞

@@ -160,7 +160,6 @@ def test_incomplete(self):
ai("","eval")
ai("\n","eval")
ai("(","eval")
ai("(\n\n\n","eval")
Copy link
Member Author

@pablogsal pablogsal Jan 14, 2021

Choose a reason for hiding this comment

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

The EOF was reached in a different line before but now it raises the same error as the case without newlines (because the unopen parentheses are at the same place). I think we can allow that to happen.

@pablogsal pablogsal force-pushed the parens branch 2 times, most recently from 2a7d535 to b5bfa50 Compare January 14, 2021 23:04
@pablogsal pablogsal marked this pull request as ready for review January 14, 2021 23:15
@pablogsal
Copy link
Member Author

I would like this PR to be exposed as soon as possible to new users testing 3.10 so we can find as many problems with this as possible (if there are any), given that this actively exercises the code added in #24140. If nobody can review this by the end of the week I would like to go ahead and land it and we can tweak it later unless someone has concerns with this.

@lysnikolaou
Copy link
Member

I'm so sorry for not replying sooner. I got distracted by other stuff and forgot about this. I'll find some time to review it by Wednesday evening. I hope that's okay and sorry again.

@pablogsal
Copy link
Member Author

pablogsal commented Jan 18, 2021

I hope that's okay and sorry again.

Absolutely! Don't worry, I totally understand and there is no problem. Also, don't feel pressured to review this if you don't have time. I wrote the message in case that nobody has time to review this in the short term because I wanted some early exposure for this :)

Also, tell me if you need more time to go through this and I can hold it for more time

Copy link
Member

@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀 Great work!

Do the Windows warnings bother us or is it okay to merge with those?

@pablogsal
Copy link
Member Author

Do the Windows warnings bother us or is it okay to merge with those?

I would merge and then investigate the proper way to fix it. It probably requires a cast or changing the type of the parent stack but maybe it requires changes somewhere else due to type inconsistency across these fields and I prefer to investigate separately if that's ok with you :)

@lysnikolaou
Copy link
Member

Do the Windows warnings bother us or is it okay to merge with those?

I would merge and then investigate the proper way to fix it. It probably requires a cast or changing the type of the parent stack but maybe it requires changes somewhere else due to type inconsistency across these fields and I prefer to investigate separately if that's ok with you :)

Yup. Go!

@pablogsal pablogsal merged commit d6d6371 into python:master Jan 19, 2021
@pablogsal
Copy link
Member Author

Yup. Go!

Let's see how many weird edge cases we found after this 😆

@pablogsal pablogsal deleted the parens branch May 19, 2021 18:57
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.

5 participants