[issue39545] await is not supported in f-string in 3.6

New submission from Serhiy Storchaka <storchaka+cpython@gmail.com>: The following code is compiled in 3.7, but is a syntax error in 3.6. async def f(x): f"{await x}" I have not found mentioning this change in What's New, and it looks grammatically correct. It looks as a bug in 3.6. It may be too later to fix it in 3.6, but at least it should be documented. ---------- assignee: docs@python components: Documentation, Interpreter Core messages: 361317 nosy: docs@python, eric.smith, serhiy.storchaka priority: normal severity: normal status: open title: await is not supported in f-string in 3.6 type: behavior versions: Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Mariatta <mariatta@python.org> added the comment: The answer I got from Yury before was: "Before 3.7 async and await were not proper keywords, so the interpreter did not recognize them in some contexts." ---------- nosy: +Mariatta _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment: Yes, await was recognized only in asynchronous functions. f-strings involve a separate parsing step for subexpressions, and it is not aware that it is in an asynchronous function. Seems the fix was unintentional, but it should documented in any case. ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Change by Karthikeyan Singaravelan <tir.karthi@gmail.com>: ---------- nosy: +yselivanov _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Rohit Sanjay <sanjay.rohit2@gmail.com> added the comment: Hey, I'd like to work on this issue. Seems like an easy fix. Can you please help me out with where I will need to add the documentation for this? ---------- nosy: +rohitsanjay _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Elena Oat <oat.elena@gmail.com> added the comment: There was no update on this since 02/04, so I will work on this as I am at the PyCascades sprints right now. ---------- nosy: +Elena.Oat _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Change by Elena Oat <oat.elena@gmail.com>: ---------- keywords: +patch pull_requests: +17807 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18433 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Change by Elena Oat <oat.elena@gmail.com>: ---------- pull_requests: +17808 pull_request: https://github.com/python/cpython/pull/18434 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Ned Deily <nad@python.org> added the comment: New changeset a2963f09629a0a8c63e9acef79c1dcc0a040ddb6 by Elena Oat in branch '3.6': bpo-39545: docs: do not use await in f-strings (GH-18434) https://github.com/python/cpython/commit/a2963f09629a0a8c63e9acef79c1dcc0a04... ---------- nosy: +ned.deily _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Ned Deily <nad@python.org> added the comment: Thanks for the PR! We don't normally accept doc changes for branches in security-fix mode but this seems like a worthwhile exception. ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment: Needed also notes in 3.7+. ---------- resolution: fixed -> stage: resolved -> status: closed -> open versions: +Python 3.7, Python 3.8, Python 3.9 -Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Change by Serhiy Storchaka <storchaka+cpython@gmail.com>: ---------- pull_requests: +17830 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18456 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Change by Serhiy Storchaka <storchaka+cpython@gmail.com>: ---------- pull_requests: +17833 pull_request: https://github.com/python/cpython/pull/18459 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Ned Deily <nad@python.org> added the comment: New changeset cebe9ee988837b292f2c571e194ed11e7cd4abbb by Serhiy Storchaka in branch '3.6': bpo-39545: Document restrictions on "await" and "async for" in f-strings. (GH-18459) https://github.com/python/cpython/commit/cebe9ee988837b292f2c571e194ed11e7cd... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset f632736023502816f2e6bd714d1b48c81aa2ccc1 by Serhiy Storchaka in branch 'master': bpo-39545: Document changes in the support of await in f-strings. (GH-18456) https://github.com/python/cpython/commit/f632736023502816f2e6bd714d1b48c81aa... ---------- nosy: +miss-islington _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +17881 pull_request: https://github.com/python/cpython/pull/18505 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +17882 pull_request: https://github.com/python/cpython/pull/18506 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 46cf4fc8a5646ca35f7d1ac06d2ef33eb9efca1d by Miss Islington (bot) in branch '3.7': bpo-39545: Document changes in the support of await in f-strings. (GH-18456) https://github.com/python/cpython/commit/46cf4fc8a5646ca35f7d1ac06d2ef33eb9e... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 581b8606ca0609cf36c4eb9a5bb025eb77540e5e by Miss Islington (bot) in branch '3.8': bpo-39545: Document changes in the support of await in f-strings. (GH-18456) https://github.com/python/cpython/commit/581b8606ca0609cf36c4eb9a5bb025eb775... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________

Change by Serhiy Storchaka <storchaka+cpython@gmail.com>: ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: +Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39545> _______________________________________
participants (7)
-
Elena Oat
-
Karthikeyan Singaravelan
-
Mariatta
-
miss-islington
-
Ned Deily
-
Rohit Sanjay
-
Serhiy Storchaka