[issue44838] SyntaxError: New message "expected 'else' after 'if' expression" wrongly shown

2021-08-05 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue44838] SyntaxError: New message "expected 'else' after 'if' expression" wrongly shown

2021-08-05 Thread miss-islington
miss-islington added the comment: New changeset b1bd16c2528295b8b28395827f6b589dccea0624 by Pablo Galindo Salgado in branch '3.10': [3.10] bpo-44838: Refine the custom syntax errors for invalid 'if' expressions (GH-27615). (GH-27616)

[issue44838] SyntaxError: New message "expected 'else' after 'if' expression" wrongly shown

2021-08-05 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- pull_requests: +26110 stage: -> patch review pull_request: https://github.com/python/cpython/pull/27616 ___ Python tracker ___

[issue44838] SyntaxError: New message "expected 'else' after 'if' expression" wrongly shown

2021-08-05 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset f5cbea6b1b5fc39cca377c6cc93f222916015fc4 by Pablo Galindo Salgado in branch 'main': bpo-44838: Refine the custom syntax errors for invalid 'if' expressions (GH-27615)

[issue44838] SyntaxError: New message "expected 'else' after 'if' expression" wrongly shown

2021-08-05 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Opened https://github.com/python/cpython/pull/27615 -- ___ Python tracker ___ ___

[issue44838] SyntaxError: New message "expected 'else' after 'if' expression" wrongly shown

2021-08-05 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > but when you do the test to identify if an 'else' is missing, could the fact > that there is a colon instead of the expected 'else' be used to avoid > misidentifying this case? Yeah! That is what I was thinking. The key here is that the ':' is the

[issue44838] SyntaxError: New message "expected 'else' after 'if' expression" wrongly shown

2021-08-05 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- keywords: +patch pull_requests: +26109 stage: -> patch review pull_request: https://github.com/python/cpython/pull/27615 ___ Python tracker

[issue44838] SyntaxError: New message "expected 'else' after 'if' expression" wrongly shown

2021-08-05 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Technically this example si more or less equivalent to: [ something, blech if 42: True [Bluch]] I wonder if the better fix here is just not to raise the rule if we find a ':', which is the only token that actually makes sense after 'if'

[issue44838] SyntaxError: New message "expected 'else' after 'if' expression" wrongly shown

2021-08-05 Thread Andre Roberge
Andre Roberge added the comment: I have no idea how the parser works ... but when you do the test to identify if an 'else' is missing, could the fact that there is a colon instead of the expected 'else' be used to avoid misidentifying this case? Note: I am keenly aware of the difficulties

[issue44838] SyntaxError: New message "expected 'else' after 'if' expression" wrongly shown

2021-08-05 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: This is a tricky one because the tokenizer doesn't see the enclosed parentheses because is actually closed (the second print has two ')' parentheses). This is tricky indeed because the parser is parsing the ( after the print as a group, not as a

[issue44838] SyntaxError: New message "expected 'else' after 'if' expression" wrongly shown

2021-08-05 Thread Lysandros Nikolaou
Lysandros Nikolaou added the comment: Oh, this is a difficult one. It's caused by GH-27506 that was recently added to produce better errors for things like `print('hello' if something)`, where the correct syntax is `print('hello' if something else 'hi'). This is going to have a lot of

[issue44838] SyntaxError: New message "expected 'else' after 'if' expression" wrongly shown

2021-08-05 Thread Andre Roberge
New submission from Andre Roberge : Given the following code containing no if expression (only if statements): if True: print('hello' if 2: print(123)) The following traceback is generated in Python 3.10.0RC1 File "...\example.py", line 2 print('hello' ^^^