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 lukasz.langa
Recipients BTaskaya, Mark.Shannon, benjamin.peterson, brett.cannon, lukasz.langa, pablogsal, xiaket, yselivanov
Date 2021-09-29.13:17:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1632921429.6.0.989095203821.issue44896@roundup.psfhosted.org>
In-reply-to
Content
Sorry, I think we shouldn't be changing `ast.py` this way. To reiterate my review comment from the PR:

I think we should just let this go and instead advertise that if you put new synthetic nodes in a tree, you have to either:
- provide `lineno` and `col_offset` yourself; or
- use `fix_missing_locations()` to fill out the information for you.

The problem with the logic that I commented on twice now (on the PR) is one reason for my opinion. Another is bigger though:

Suppose user code is replacing nodes or just inserting new ones. This operation not only creates nodes without location attributes. It also in all likelihood *moves* locations of type comments and those aren't updated (for example, `_type_ignores[123]` should now really be `_type_ignores[125]` to still point at the same tokens). So user code shouldn't be naive when it comes to missing locations, and we definitely shouldn't paper over missing locations.
History
Date User Action Args
2021-09-29 13:17:09lukasz.langasetrecipients: + lukasz.langa, brett.cannon, benjamin.peterson, Mark.Shannon, yselivanov, pablogsal, BTaskaya, xiaket
2021-09-29 13:17:09lukasz.langasetmessageid: <1632921429.6.0.989095203821.issue44896@roundup.psfhosted.org>
2021-09-29 13:17:09lukasz.langalinkissue44896 messages
2021-09-29 13:17:09lukasz.langacreate