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.

classification
Title: Improve / Clear ASDL generator
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, pablogsal, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2020-05-06 11:17 by BTaskaya, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19952 merged BTaskaya, 2020-05-06 11:24
PR 19968 merged BTaskaya, 2020-05-06 19:32
PR 20193 merged BTaskaya, 2020-05-18 21:13
PR 26858 merged BTaskaya, 2021-06-22 18:03
PR 26918 merged BTaskaya, 2021-06-26 18:55
Messages (17)
msg368235 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-05-06 11:17
- Better error messages with punctuation
- Py_UNREACHABLE() for unreachable states
- Removal of several 'unused' and 'undocumented (in Zephyr ASDL spec) built-in types.
msg368238 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-05-06 11:46
You just read my thoughts. That's what I was going to do tonight. ;)
msg368239 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-05-06 11:52
> You just read my thoughts. That's what I was going to do tonight. ;)

:) Awesome. Well I'll plan to continue this; @pablogsal and I was discussing the idea of extracting _ast.AST subclasses to python level (which would save a lot of time for new additions). So my primary goal is clearing bunch of old stuff / making it extendable and clean.
msg368240 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-05-06 11:53
Currently working on implementing some items from this TODO https://github.com/eliben/asdl_parser/blob/master/TODO
msg368245 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-05-06 13:00
I was also thinking about getting rid of "string" nodes and just use Constant for those. Having the strings raw make the AST inconsistent because nodes that are 'strings' do not have line numbers and other metadata, making tools that need the source to report stuff more complex than it should.

What are your opinions on this @serhiy.storchaka and  @BTaskaya?
msg368247 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-05-06 13:16
> I was also thinking about getting rid of "string" nodes and just use Constant for those. Having the strings raw make the AST inconsistent because nodes that are 'strings' do not have line numbers and other metadata, making tools that need the source to report stuff more complex than it should.

I'm +1 on that (especially for finding import aliases, as we discussed earlier), if necessary precautions happen to ensure minimum breakage (from what I understand, it is something that will break everyone's code. Maybe we can implement custom Constant.__str__? and other different things to ensure it breaks small).
msg368248 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-05-06 13:17
"string" is only used for

* type_comment in a number of statements
* kind in Constant
* tag in type_ignore

For which of them a line number is meaningful and useful?
msg368250 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-05-06 13:34
> For which of them a line number is meaningful and useful?

Apologies, I was thinking of 'identifier', which is basically a PyObject representing a string. For instance, when parsing function calls like

x = ast.parse("f(x=435)")

the 'arg' attribute of the keyword is just the string 'x', without any metadata about it (like column offset and such).
msg368251 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-05-06 13:35
Oh, I confuse with it identifier. IMHO replacing identifier with Constant would infer position in some cases.
msg368252 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-05-06 13:41
A real world example would be tools like `unimport`, that try to remove a certain part of import by looking start/end column offsets. Before (lib2to3), it was using tokens to manipulate source, and what I can tell is that having position information on multi line from imports would be a life saver for tool authors.
msg368257 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-05-06 14:29
New changeset 091951a67c832db83c60f4eb22f1fb474b70e635 by Batuhan Taskaya in branch 'master':
bpo-40528: Improve and clear several aspects of the ASDL definition code for the AST (GH-19952)
https://github.com/python/cpython/commit/091951a67c832db83c60f4eb22f1fb474b70e635
msg368365 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-05-07 18:28
Next is using asdl_int_seq for all simple sum types, and not for only cmpop. Looks like it is hardcoded to use it, and I plan to refactor this in a way that might save some time in python implementation of classes (also it will solve this bug). For not conflicting, I'll wait GH 19968.
msg369281 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-05-18 17:42
New changeset 63b8e0cba3d43e53a8dd8878ee1443c8427f462d by Batuhan Taskaya in branch 'master':
bpo-40528: Improve AST generation script to do builds simultaneously (GH-19968)
https://github.com/python/cpython/commit/63b8e0cba3d43e53a8dd8878ee1443c8427f462d
msg396353 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2021-06-22 16:29
New changeset 35ad425866d591c33d7f2be2b9da8bce2bff9523 by Batuhan Taskaya in branch 'main':
bpo-40528: Implement a metadata system for ASDL Generator (GH-20193)
https://github.com/python/cpython/commit/35ad425866d591c33d7f2be2b9da8bce2bff9523
msg396477 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2021-06-24 12:16
New changeset 6c76df2b86d742cc294beae7f9b6bafabb946ad5 by Batuhan Taskaya in branch 'main':
bpo-40528: move asdl identifier collection to the new metadata system (GH-26858)
https://github.com/python/cpython/commit/6c76df2b86d742cc294beae7f9b6bafabb946ad5
msg396583 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2021-06-27 14:58
New changeset 107a2c59c91b3911bdd6dfdb83271c588c506a5a by Batuhan Taskaya in branch 'main':
bpo-40528: fix is_simple(sum)s behavior for attributes (GH-26918)
https://github.com/python/cpython/commit/107a2c59c91b3911bdd6dfdb83271c588c506a5a
msg396584 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2021-06-27 14:59
These were all the cleanups on my checklist, so can close the issue now. I'll probably create other issues if something additional comes up
History
Date User Action Args
2022-04-11 14:59:30adminsetgithub: 84708
2021-06-27 14:59:34BTaskayasetstatus: open -> closed
resolution: fixed
messages: + msg396584

stage: patch review -> resolved
2021-06-27 14:58:40BTaskayasetmessages: + msg396583
2021-06-26 18:55:38BTaskayasetpull_requests: + pull_request25491
2021-06-24 12:16:10BTaskayasetmessages: + msg396477
2021-06-22 18:03:09BTaskayasetpull_requests: + pull_request25435
2021-06-22 16:29:49BTaskayasetmessages: + msg396353
2020-05-18 21:13:51BTaskayasetpull_requests: + pull_request19494
2020-05-18 17:42:17pablogsalsetmessages: + msg369281
2020-05-07 18:28:24BTaskayasetmessages: + msg368365
2020-05-06 19:32:00BTaskayasetstage: patch review
pull_requests: + pull_request19283
2020-05-06 14:29:40pablogsalsetmessages: + msg368257
2020-05-06 13:41:52BTaskayasetmessages: + msg368252
2020-05-06 13:35:09BTaskayasetmessages: + msg368251
2020-05-06 13:34:22pablogsalsetmessages: + msg368250
2020-05-06 13:17:18serhiy.storchakasetmessages: + msg368248
2020-05-06 13:16:11BTaskayasetmessages: + msg368247
2020-05-06 13:00:20pablogsalsetmessages: + msg368245
2020-05-06 11:53:27BTaskayasetmessages: + msg368240
2020-05-06 11:52:23BTaskayasetnosy: + pablogsal

messages: + msg368239
stage: patch review -> (no value)
2020-05-06 11:46:41serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg368238
2020-05-06 11:24:40BTaskayasetkeywords: + patch
stage: patch review
pull_requests: + pull_request19268
2020-05-06 11:17:00BTaskayacreate