classification
Title: Syntax Error not as detailed as shown
Type: behavior Stage: resolved
Components: Parser Versions: Python 3.10
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: aroberge, ezio.melotti, khokhareesa.home, lys.nikolaou, mrabarnett, pablogsal
Priority: normal Keywords:

Created on 2021-06-17 22:36 by khokhareesa.home, last changed 2021-06-24 23:34 by khokhareesa.home. This issue is now closed.

Files
File name Uploaded Description Edit
Untitled.png khokhareesa.home, 2021-06-17 22:36 Pic of the error
Messages (4)
msg396023 - (view) Author: Eesa Ibrahim Khokhar (khokhareesa.home) * Date: 2021-06-17 22:36
I was testing the new features for python 3.10 beta 3, and noticed the errors were not as detailed as shown in the docs.

I have an image below:


In the docs, it was said that the entire generator statement would be pointed out by carets. However, it only pointed out 'for', and the error was not as detailed as shown in the docs.
msg396024 - (view) Author: Andre Roberge (aroberge) * Date: 2021-06-17 23:39
Your example is different than the one in the documentation (What's new).

>>> (x, x for x in range(7))  # Your example
  File "<stdin>", line 1
    (x, x for x in range(7))
          ^^^
SyntaxError: invalid syntax

>>> foo(x, x for x in range(7))  # Example similar to the docs
  File "<stdin>", line 1
    foo(x, x for x in range(7))
           ^^^^^^^^^^^^^^^^^^^
SyntaxError: Generator expression must be parenthesized

>>> [x, x for x in range(7)]  # Yet a different example
  File "<stdin>", line 1
    [x, x for x in range(7)]
     ^^^^
SyntaxError: did you forget parentheses around the comprehension target?
msg396079 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-06-18 19:09
Indeed, as Andre mentions your example is different because in you case the call is interpreted as a generator comprehension, not as a function call.
msg396514 - (view) Author: Eesa Ibrahim Khokhar (khokhareesa.home) * Date: 2021-06-24 23:34
OK, Thanks for letting me know!

On Fri, Jun 18, 2021 at 3:09 PM Pablo Galindo Salgado <
report@bugs.python.org> wrote:

>
> Pablo Galindo Salgado <pablogsal@gmail.com> added the comment:
>
> Indeed, as Andre mentions your example is different because in you case
> the call is interpreted as a generator comprehension, not as a function
> call.
>
> ----------
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue44447>
> _______________________________________
>
History
Date User Action Args
2021-06-24 23:34:04khokhareesa.homesetmessages: + msg396514
2021-06-18 19:09:01pablogsalsetstatus: open -> closed
resolution: not a bug
messages: + msg396079

stage: resolved
2021-06-18 18:56:38Jelle Zijlstrasetnosy: + lys.nikolaou, pablogsal
type: performance -> behavior
components: + Parser, - Regular Expressions
2021-06-17 23:39:18arobergesetnosy: + aroberge
messages: + msg396024
2021-06-17 22:36:13khokhareesa.homecreate