Mailing List Archive

[issue44447] Syntax Error not as detailed as shown
New submission from Eesa Ibrahim Khokhar <khokhareesa.home@gmail.com>:

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.

----------
components: Regular Expressions
files: Untitled.png
messages: 396023
nosy: ezio.melotti, khokhareesa.home, mrabarnett
priority: normal
severity: normal
status: open
title: Syntax Error not as detailed as shown
type: performance
versions: Python 3.10
Added file: https://bugs.python.org/file50116/Untitled.png

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue44447>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue44447] Syntax Error not as detailed as shown [ In reply to ]
Andre Roberge <andre.roberge@gmail.com> added the comment:

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?

----------
nosy: +aroberge

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue44447>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue44447] Syntax Error not as detailed as shown [ In reply to ]
Change by Jelle Zijlstra <jelle.zijlstra@gmail.com>:


----------
components: +Parser -Regular Expressions
nosy: +lys.nikolaou, pablogsal
type: performance -> behavior

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue44447>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue44447] Syntax Error not as detailed as shown [ In reply to ]
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>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue44447] Syntax Error not as detailed as shown [ In reply to ]
Eesa Ibrahim Khokhar <khokhareesa.home@gmail.com> added the comment:

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>
> _______________________________________
>

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue44447>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com