Yury Selivanov added the comment:
Sorry for not responding earlier, I'm on vacation and don't check email too
often.
While investigating what can be done in tokenizer.c to fix some of the bugs
that Stefan pointed out, I discovered a simpler approach: instead of checking
what kind of function we have on top of the stack, I now have a counter of
nested async functions. This aligns nicely with what Nick said on python-dev
once: we essentially treat 'async def' as a future import, everything inside it
parses differently.
In other words, before this patch:
async def foo():
def bar():
async = 1
was legal, now it's a syntax error, as 'async' will be parsed as 'ASYNC' token.
This simplifies the implementation of tokenizer.c hacks, fixes all of the bugs
that Stefan posted here, *and* enables one-line 'async' functions:
async def foo(): await bar() # legal with the patch
It will also help with migrating the code to Python 3.7 when async/await will
become proper keywords.
And, with this patch we can effectively remove the shortcomings section from
the PEP 492
(https://www.python.org/dev/peps/pep-0492/#transition-period-shortcomings).
Please review the attached patch, it would be great if we can commit it before
3.5beta4.
----------
assignee: -> yselivanov
keywords: +patch
nosy: +haypo, ncoghlan
priority: normal -> release blocker
stage: -> patch review
versions: +Python 3.5, Python 3.6
Added file: http://bugs.python.org/file39964/issue24619.1.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24619>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com