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-25.18:30:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1595701834.13.0.397134416072.issue41388@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-07-25 18:30:34Lewis Ballsetrecipients: + Lewis Ball, terry.reedy, taleinat, Alexey Burdin
2020-07-25 18:30:34Lewis Ballsetmessageid: <1595701834.13.0.397134416072.issue41388@roundup.psfhosted.org>
2020-07-25 18:30:34Lewis Balllinkissue41388 messages
2020-07-25 18:30:33Lewis Ballcreate