This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Lewis Ball
Recipients Alexey Burdin, Lewis Ball, terry.reedy
Date 2020-07-25.00:37:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1595637430.03.0.832698692005.issue41388@roundup.psfhosted.org>
In-reply-to
Content
A minimal example of the same issue seems to be:
```
(1 if x
 else 0)
```
In this case the parentheses matching also fails. It only ever seems to fail when `else` is the first word on a newline inside brackets, and adding the line break elsewhere in the above statement will not cause the matching to fail. 

I imagine it stops looking for the matching parentheses when it gets to the `else` statement, as an `else` when part of an `if/else` cannot be inside parentheses. Obviously the exception to this is the ternary operator.

Bizarrely, it only seems to fail the first time it encounters this issue. Any subsequent code with the same pattern seems to be matched fine. So in the following example, the second brackets get matched without an issue:

```
(1 if x
 else 0)

(1 if x
 else 0)
```

Hopefully someone more familiar with the source code can shed some light on this!
History
Date User Action Args
2020-07-25 00:37:10Lewis Ballsetrecipients: + Lewis Ball, terry.reedy, Alexey Burdin
2020-07-25 00:37:10Lewis Ballsetmessageid: <1595637430.03.0.832698692005.issue41388@roundup.psfhosted.org>
2020-07-25 00:37:09Lewis Balllinkissue41388 messages
2020-07-25 00:37:09Lewis Ballcreate