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, taleinat, terry.reedy
Date 2020-07-26.00:05:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1595721923.56.0.705875685456.issue41388@roundup.psfhosted.org>
In-reply-to
Content
Okay, on further examination `find_good_parse_start` first looks for a line ending with ':\n', and then looks to match _synchre on that line. If it can't find any line ending in ':\n' then it will just look for the first occurrence of something in _synchre to truncate on. If it can't find anything at that point, it just doesn't truncate and the whole code is checked for a bracket match.

So the reason that 
```
else
(
else)
```
works is because there is no `:` after the first else, and adding `:` will cause the matching to fail.

This seems reasonable, and I was probably too quick to say that the function goes back further than it needs to when looking to truncate.

It seems like then that `else` being removed from _synchre will fix this, and mean that the only time brackets aren't matched are when invalid code is typed, something like:
```
(
def)
```

I can put in a PR for this tomorrow (probably removing `yield` at the same time) if this sounds like the right fix.

P.S. Here is an example of the similar `yield` error that Terry alluded to:
```
def f():
    for i in range(10):
        (
        yield x)
```
History
Date User Action Args
2020-07-26 00:05:23Lewis Ballsetrecipients: + Lewis Ball, terry.reedy, taleinat, Alexey Burdin
2020-07-26 00:05:23Lewis Ballsetmessageid: <1595721923.56.0.705875685456.issue41388@roundup.psfhosted.org>
2020-07-26 00:05:23Lewis Balllinkissue41388 messages
2020-07-26 00:05:23Lewis Ballcreate