Message372688
_maybe_compile currently compiles the possibly complete statement up to 3 times -- with C-coded compile. Without doing any timing tests, I wondered if 3 times is really necessary. Nick suggested that using the tokenize module to determine the number of hanging indents, combined with some yet to be determined logic, might be an alternative. But since tokenize is written in Python, the result might not be any faster.
Checking the error message aims at specifically fixing this issue. But I am not sure if the check is sufficient or if more logic is needed.
"def a():\n nonlocal c\n" should ideally raise.
"def a():\n def b():\n nonlocal c\n" must not.
At least the second should be used for a new test.
I would start by adding debug prints to see the result of each compile and then testing with those two lines. |
|
Date |
User |
Action |
Args |
2020-06-30 13:02:02 | terry.reedy | set | recipients:
+ terry.reedy, ncoghlan, r.david.murray, Mark.Shannon, Rosuav, Esa.Peuha, mbussonn, cheryl.sabella, lys.nikolaou, pablogsal, RJ722 |
2020-06-30 13:02:02 | terry.reedy | set | messageid: <1593522122.05.0.912450174245.issue19335@roundup.psfhosted.org> |
2020-06-30 13:02:02 | terry.reedy | link | issue19335 messages |
2020-06-30 13:02:01 | terry.reedy | create | |
|