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 BTaskaya
Recipients BTaskaya, Mark.Shannon, benjamin.peterson, brett.cannon, pablogsal, xiaket, yselivanov
Date 2021-08-14.14:42:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1628952142.63.0.343772088419.issue44896@roundup.psfhosted.org>
In-reply-to
Content
I don't think this is really an issue considering some other functionalities that consumes AST code (e.g `compile`) will expect it to be annotated with location metadata. This is why the `ast` module already comes bundled with a utility function called `fix_missing_locations` which in your example would work;

> print(ast.unparse(bad))
> print(ast.unparse(ast.fix_missing_locations(bad)))

Though I recall seeing this error once before, and since there also some counter examples (e.g ast.increment_lineno) that assume an AST node might lack of these attributes even though the nodes declare them makes it worth to fix.
History
Date User Action Args
2021-08-14 14:42:22BTaskayasetrecipients: + BTaskaya, brett.cannon, benjamin.peterson, Mark.Shannon, yselivanov, pablogsal, xiaket
2021-08-14 14:42:22BTaskayasetmessageid: <1628952142.63.0.343772088419.issue44896@roundup.psfhosted.org>
2021-08-14 14:42:22BTaskayalinkissue44896 messages
2021-08-14 14:42:22BTaskayacreate