Lewis Ball <lrjb...@gmail.com> added the comment:

So it looks like `pyparse.Parser.find_good_parse_start` is responsible for 
truncating the code to only look for the matching bracket in the current 
statement, which uses _synchre.

Testing it out, it sometimes will go to the most recent match of _synchre, but 
will sometimes go back to an even earlier match in the code, which is why 
something like
```
else
(
else)
```
manages to match without an issue. The `find_good_parse_start` will truncate at 
the first `else` in this case, instead at the second one.

Removing `else` from the _synchre regex did solve this problem for me though, 
as `find_good_parse_start` will then try to truncate even earlier when looking 
for the start of the statement, which will be before the opener. Although, I 
haven't checked what else would be affected by this change. I am not sure why 
this worked for me and did not work for you Terry.

Also, even with this fix it seems like 'find_good_parse_start` goes back 
further than it needs to. Fixing that may not change much, but would offer a 
slight performance increase.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41388>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to