-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for always tokenizing async/await as keywords
Fixes psf#593 I looked into this bug with @ambv and @carljm, and we reached the conclusion was that it's not possible for the tokenizer to determine if async/await is a keyword inside all possible generators without breaking the grammar for older versions of Python. Instead, we introduce a new tokenizer mode for Python 3.7+ that will cause all async/await instances to get parsed as a reserved keyword, which should fix async/await inside generators.
- Loading branch information
Showing
8 changed files
with
190 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
def async(): | ||
pass | ||
|
||
|
||
def await(): | ||
pass | ||
|
||
|
||
await = lambda: None | ||
async = lambda: None | ||
async() | ||
await() | ||
|
||
|
||
def sync_fn(): | ||
await = lambda: None | ||
async = lambda: None | ||
async() | ||
await() | ||
|
||
|
||
async def async_fn(): | ||
await async_fn() | ||
|
||
|
||
# output | ||
def async(): | ||
pass | ||
|
||
|
||
def await(): | ||
pass | ||
|
||
|
||
await = lambda: None | ||
async = lambda: None | ||
async() | ||
await() | ||
|
||
|
||
def sync_fn(): | ||
await = lambda: None | ||
async = lambda: None | ||
async() | ||
await() | ||
|
||
|
||
async def async_fn(): | ||
await async_fn() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters