Message374298
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)
``` |
|
Date |
User |
Action |
Args |
2020-07-26 00:05:23 | Lewis Ball | set | recipients:
+ Lewis Ball, terry.reedy, taleinat, Alexey Burdin |
2020-07-26 00:05:23 | Lewis Ball | set | messageid: <1595721923.56.0.705875685456.issue41388@roundup.psfhosted.org> |
2020-07-26 00:05:23 | Lewis Ball | link | issue41388 messages |
2020-07-26 00:05:23 | Lewis Ball | create | |
|