Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PEP 492, Coroutines with async and await syntax #114

Merged
merged 3 commits into from
Jul 28, 2018
Merged

Support PEP 492, Coroutines with async and await syntax #114

merged 3 commits into from
Jul 28, 2018

Conversation

odcinek
Copy link
Contributor

@odcinek odcinek commented Aug 4, 2017

No description provided.

@Psycojoker
Copy link
Member

Okay, this one is not funny at all. In python3 magic has been done meaning that "await" and "async" are not real keywords but NAME that can be used as so for retrocompatibility, like in:

await = 42
async = 42

This PR doesn't allow to do that sadly and that's a bug. I'm trying to find a way to do that but haven't had a lot of success. I might need to add a step in the lexer for this special case yet again >.>

@Psycojoker Psycojoker merged commit 87b8aa6 into PyCQA:master Jul 28, 2018
@Psycojoker
Copy link
Member

Psycojoker commented Jul 29, 2018

So, I finally merged this one. There were ... a lot of more work to do, this was not an easy subject at all :/

As a summary here are the things I've changed/added:

  • async/await aren't keyword in python despite the common intuition, those are "NAME", so I've changed them to that (this required some tweaks in the grammar parsor and quite a lot of exploration)
  • there were quite some bug like missing definitions in render.py, a function name overwrite, a additional declaration for funcdef that was unused, async where added in "for a in b: pass\nelse: pass" case
  • design modification: await is not an alone node but a node with a value which is the wrapper atomtrailers (I'm still not 100% sure that this is the most intuitive way)
  • async is not an alone node anymore but attributes to the wrapper nodes to flatter the things
  • add way more tests

I'm not 100% sure everything is fine and will hold on the future, the work on RedBaron (when I'll do it...) should confirm that or raises new bugs.

Here is the diff if someone is interested one day 786d723...531c2b2 (there are some indentation fixing in the middle, ignore that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants