Author terry.reedy
Recipients Esa.Peuha, Mark.Shannon, RJ722, Rosuav, cheryl.sabella, lys.nikolaou, mbussonn, ncoghlan, pablogsal, r.david.murray, terry.reedy
Date 2020-06-30.13:02:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
_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:02terry.reedysetrecipients: + terry.reedy, ncoghlan, r.david.murray, Mark.Shannon, Rosuav, Esa.Peuha, mbussonn, cheryl.sabella, lys.nikolaou, pablogsal, RJ722
2020-06-30 13:02:02terry.reedysetmessageid: <>
2020-06-30 13:02:02terry.reedylinkissue19335 messages
2020-06-30 13:02:01terry.reedycreate