Decoratored functions parsed differently by ast stdlib between 3.7 and 3.8

Terry Reedy tjreedy at udel.edu
Sat May 1 00:46:36 EDT 2021


On 4/30/2021 11:07 PM, Mike Lee Williams wrote:
> On Friday, April 30, 2021 at 7:55:10 PM UTC-7, Mike Lee Williams wrote:
>> This trivial bit of code is parsed differently by the ast module between python
>> 3.7 and python 3.8. I'm trying to figure out what changed and why, and once I
>> know that, if it's possible and desirable to retain the 3.7 behavior for my use
>> case (which needs to give the same result for this input on 3.7 and 3.8).
> 
> Answering my own question: the behavior was changed by https://github.com/python/cpython/pull/9731.

Since this patch, Mark Shannon has revised line numbering and tracing 
and replaced the internal lineno data structure. Your example code still 
outputs 2.  So Mark either missed this case or considers it correct.

--
Terry Jan Reedy



More information about the Python-list mailing list