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 emma_smith
Recipients emma_smith, gforcada, levkivskyi, nitishch, serhiy.storchaka
Date 2018-04-07.21:29:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
In my PR, I added `def_lineno` and `class_lineno` as fields in the ASDL, instead of attributes (since constructors cannot have attributes, only types can). This means they show up in `ast.dump` which is probably not the desired behavior, as it makes the dumped ast whitespace/line offset sensitive.

Therefore I propose we change the line number of the nodes to be the one of the def/class statement. It seems based on [this commit](https://github.com/python/cpython/commit/09aaa88328a5083469b2682230c7f3c62942afab) that the change was done to fix inspect.getsource (so that it started on the first decorator), but I think it is much more logical for inspect to handle decorated items instead of having the ast lie.

One other option could be for a modified ast to have a decorated node, which holds the decorator list, and the class/function. This has the possible downside of being a not-insignificant change to the ast.
History
Date User Action Args
2018-04-07 21:29:28emma_smithsetrecipients: + emma_smith, serhiy.storchaka, levkivskyi, nitishch, gforcada
2018-04-07 21:29:28emma_smithsetmessageid: <[email protected]>
2018-04-07 21:29:28emma_smithlinkissue33211 messages
2018-04-07 21:29:28emma_smithcreate