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: Bad name into power operator syntax
Type: Stage: resolved
Components: Documentation Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Chema Cortés, Guido Treutwein, Yury.Selivanov, docs@python, python-dev, r.david.murray, rjordens, serhiy.storchaka, yselivanov, zach.ware
Priority: normal Keywords: patch

Created on 2016-01-19 14:41 by Chema Cortés, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue26156_power.patch rjordens, 2016-05-05 21:47 review
issue26156_await_power.patch serhiy.storchaka, 2016-05-06 04:41 review
Messages (18)
msg258596 - (view) Author: Chema Cortés (Chema Cortés) Date: 2016-01-19 14:41
The documentation erroneously changes "primary" for "away" in the power operator syntax:

https://docs.python.org/3.6/reference/expressions.html#the-power-operator
https://docs.python.org/3.5/reference/expressions.html#the-power-operator
msg258597 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2016-01-19 14:45
The docs are correct. See the definition of the "await" expression: https://docs.python.org/3.6/reference/expressions.html#await-expression
msg261571 - (view) Author: Guido Treutwein (Guido Treutwein) Date: 2016-03-11 13:46
Yurys answer and resolution misses the point. Nobody complained about the await operator. Fact is, that in the _power_ operator (chapter 6.5) as base specification now "await" is given. This is likely to be an inadvertent copy of the previous chapter, makes no sense here and should probably be replaced by "u_expr" or similar.
msg264924 - (view) Author: Robert Jordens (rjordens) * Date: 2016-05-05 21:47
The original bug report is (apart from spelling) correct. This is a bug and it should be closed.

Please reopen.

This patch reverts the erroneous change in:

changeset:   96185:548d5704fcb3
user:        Yury Selivanov <yselivanov@sprymix.com>
date:        Thu May 21 11:50:30 2015 -0400
summary:     Issue 24180: Documentation for PEP 492 changes.
msg264925 - (view) Author: Robert Jordens (rjordens) * Date: 2016-05-05 21:51
That should have read "... should _not_ be closed."
msg264932 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-06 04:30
The docs looks correct to me. It reflects the fact that the "await" keyword has higher priority than the power operator. "await a ** b" is identical to "(await a) ** b", not "await (a ** b)".
msg264933 - (view) Author: Yury Selivanov (Yury.Selivanov) * Date: 2016-05-06 04:32
Fwiw, I'm -1 on changing this. I think that the current names are correct.
msg264934 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-06 04:41
But to avoid confusion I propose following patch. This may be more correct, since it is strange to name the expression without "await" "await expression".
msg264935 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2016-05-06 04:45
I agree that what is currently in the docs is technically correct.  The section on the power operator:

   power ::=  await ["**" u_expr]

should be read as:

   power ::=  (["await"] primary) ["**" u_expr]

just as the definition of 'u_expr' below should be read as:

   u_expr ::=  (await ["**" u_expr]) | "-" u_expr | "+" u_expr | "~" u_expr

and 'await' should be read as:

   await ::= ["await"] (atom | attributeref | subscription | slicing | call)

Each definition builds upon previous ones.

However, it is confusing.  Could a name other than "await" be used, since "await" is easily confused with the keyword await?
msg264936 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-06 04:49
May be "w_expr"? ("a_expr" is already used for addition level).
msg264937 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2016-05-06 04:50
Let's call it "await_expr"
msg264938 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2016-05-06 04:59
+1 for await_expr
msg264939 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-06 06:10
The confusion is in the definition of await expression with optional "await". Without "await" the expression doesn't suspend the execution of coroutine. And await expression can only be used inside a coroutine function, but the power operator can be used outside.
msg264960 - (view) Author: Robert Jordens (rjordens) * Date: 2016-05-06 10:31
Ack to the new patch. It is semantically confusing that the await expression also served as the power base without any await.
msg264973 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-05-06 13:04
Sounds like it is a bit more than just confusion: given that power can be used outside a coroutine but await can't, Serhiy's formulation would seem to me to be more semantically correct, even if syntactically it is the same as the current.

I think it would regardless be better to replace 'await' with 'await_expr', so +1 on that from me as well.
msg264992 - (view) Author: Guido Treutwein (Guido Treutwein) Date: 2016-05-06 16:45
I'm with David here, in that a change would improve ease of comprehension:
I still find it strange, that the grammar symbol has the same name as the
keyword (or in the proposed version keyword+'expr'), which is never done on
more widely used levels. I would have expected something like
'coroutine_suspension', which reflects what it is and not which keyword is
required to state it.

2016-05-06 15:04 GMT+02:00 R. David Murray <report@bugs.python.org>:

>
> R. David Murray added the comment:
>
> Sounds like it is a bit more than just confusion: given that power can be
> used outside a coroutine but await can't, Serhiy's formulation would seem
> to me to be more semantically correct, even if syntactically it is the same
> as the current.
>
> I think it would regardless be better to replace 'await' with
> 'await_expr', so +1 on that from me as well.
>
> ----------
> nosy: +r.david.murray
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue26156>
> _______________________________________
>
msg265156 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-08 18:50
I think "await_expr" is good. It is not new that the keyword is a part of the grammar symbol name (yield_expression, comp_for, and_expr, or_test, lambda_expr).
msg265157 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-05-08 19:00
New changeset e876ff4e9e95 by Serhiy Storchaka in branch '3.5':
Issue #26156: Make expressions grammar description more semantically correct.
https://hg.python.org/cpython/rev/e876ff4e9e95

New changeset 61e3160310ae by Serhiy Storchaka in branch 'default':
Issue #26156: Make expressions grammar description more semantically correct.
https://hg.python.org/cpython/rev/61e3160310ae
History
Date User Action Args
2022-04-11 14:58:26adminsetgithub: 70344
2016-05-08 19:01:00serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2016-05-08 19:00:33python-devsetnosy: + python-dev
messages: + msg265157
2016-05-08 18:50:47serhiy.storchakasetassignee: docs@python -> serhiy.storchaka
messages: + msg265156
2016-05-06 16:45:22Guido Treutweinsetmessages: + msg264992
2016-05-06 13:04:57r.david.murraysetnosy: + r.david.murray
messages: + msg264973
2016-05-06 10:31:22rjordenssetmessages: + msg264960
2016-05-06 06:10:41serhiy.storchakasetmessages: + msg264939
2016-05-06 04:59:55zach.waresetmessages: + msg264938
2016-05-06 04:50:30yselivanovsetmessages: + msg264937
2016-05-06 04:49:03serhiy.storchakasetmessages: + msg264936
2016-05-06 04:45:44zach.waresetnosy: + zach.ware
messages: + msg264935
2016-05-06 04:41:23serhiy.storchakasetfiles: + issue26156_await_power.patch

messages: + msg264934
2016-05-06 04:32:13Yury.Selivanovsetnosy: + Yury.Selivanov
messages: + msg264933
2016-05-06 04:30:30serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg264932
2016-05-05 21:59:14r.david.murraysetstatus: closed -> open
resolution: not a bug -> (no value)
stage: resolved -> commit review
2016-05-05 21:51:43rjordenssetmessages: + msg264925
2016-05-05 21:47:44rjordenssetfiles: + issue26156_power.patch

nosy: + rjordens
messages: + msg264924

keywords: + patch
2016-03-11 13:46:31Guido Treutweinsetnosy: + Guido Treutwein
messages: + msg261571
2016-01-19 14:45:21yselivanovsetstatus: open -> closed

nosy: + yselivanov
messages: + msg258597

resolution: not a bug
stage: resolved
2016-01-19 14:41:26Chema Cortéscreate