[issue44947] SyntaxError: trailing comma not allowed ... misleading

2021-08-18 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 4e4d35d3325fb1e05dad43bd1ec73f14c3c5dc0a by Łukasz Langa in 
branch '3.9':
[3.9] bpo-44947: Refine the syntax error for trailing commas in import 
statements (GH-27814) (GH-27817)
https://github.com/python/cpython/commit/4e4d35d3325fb1e05dad43bd1ec73f14c3c5dc0a


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44947] SyntaxError: trailing comma not allowed ... misleading

2021-08-18 Thread Łukasz Langa

Change by Łukasz Langa :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44947] SyntaxError: trailing comma not allowed ... misleading

2021-08-18 Thread Łukasz Langa

Change by Łukasz Langa :


--
pull_requests: +26282
pull_request: https://github.com/python/cpython/pull/27817

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44947] SyntaxError: trailing comma not allowed ... misleading

2021-08-18 Thread miss-islington


miss-islington  added the comment:


New changeset 846a10fc45ef83b41d1b1b568a9ee8012f37c8c2 by Miss Islington (bot) 
in branch '3.10':
bpo-44947: Refine the syntax error for trailing commas in import statements 
(GH-27814)
https://github.com/python/cpython/commit/846a10fc45ef83b41d1b1b568a9ee8012f37c8c2


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44947] SyntaxError: trailing comma not allowed ... misleading

2021-08-18 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset b2f68b190035540872072ac1d2349e7745e85596 by Pablo Galindo Salgado 
in branch 'main':
bpo-44947: Refine the syntax error for trailing commas in import statements 
(GH-27814)
https://github.com/python/cpython/commit/b2f68b190035540872072ac1d2349e7745e85596


--
nosy: +lukasz.langa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44947] SyntaxError: trailing comma not allowed ... misleading

2021-08-18 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +26281
pull_request: https://github.com/python/cpython/pull/27816

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44947] SyntaxError: trailing comma not allowed ... misleading

2021-08-18 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
keywords: +patch
pull_requests: +26279
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/27814

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44947] SyntaxError: trailing comma not allowed ... misleading

2021-08-18 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

The problem is not the keyword, is that we are parsing correctly until the 
"and" and we find the comma there. It happens with anything that invalidates 
more items:

>>> from math import sin, cos, $ tan
  File "", line 1
from math import sin, cos, $ tan
   ^
SyntaxError: trailing comma not allowed without surrounding parentheses

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44947] SyntaxError: trailing comma not allowed ... misleading

2021-08-18 Thread Andre Roberge


Andre Roberge  added the comment:

Based on what I just read on 
https://github.com/davidhalter/parso/blob/master/parso/python/issue_list.txt
I gather that this exception is only raised in the context of an import 
statement with a trailing comma (usually followed by nothing).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44947] SyntaxError: trailing comma not allowed ... misleading

2021-08-18 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Hummm, interesting.

I wonder if this only happens with keywords or if this can be reproduced with 
other constructs

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44947] SyntaxError: trailing comma not allowed ... misleading

2021-08-18 Thread Andre Roberge


Andre Roberge  added the comment:

This message is not new to Python 3.10 as it is also shown with Python 3.9.5.

>>> from math import sin, cos, and tan
  File "", line 1
from math import sin, cos, and tan
   ^
SyntaxError: trailing comma not allowed without surrounding parentheses

--
versions: +Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44947] SyntaxError: trailing comma not allowed ... misleading

2021-08-18 Thread Andre Roberge


New submission from Andre Roberge :

Consider the following four slightly different examples:

Python 3.10.0rc1 ...

>>> from math import sin and cos
  File "", line 1
from math import sin and cos
 ^^^
SyntaxError: invalid syntax


>>> from math import sin, cos, and tan
  File "", line 1
from math import sin, cos, and tan
   ^^^
SyntaxError: trailing comma not allowed without surrounding parentheses


>>> from math import (sin, cos,) and tan
  File "", line 1
from math import (sin, cos,) and tan
 ^^^
SyntaxError: invalid syntax


>>> from math import sin, cos and tan
  File "", line 1
from math import sin, cos and tan
  ^^^
SyntaxError: invalid syntax


In all four cases, the keyword 'and' is correctly identified as causing the 
error. In the second case, the message given may suggest that adding 
parentheses is all that is needed to correct the problem; however, that is 
"obviously" not the case as shown in the third case.

**Perhaps** when a _keyword_ like 'and' is identified as a problem, a generally 
better message would be something like

SyntaxError: the keyword 'and' is not allowed here

leaving out all guesses like 'surrounding by parentheses', "meaning == instead 
of =", 'perhaps forgot a comma', etc., which are sometimes added by Python 
3.10+ ?

I am fully and painfully aware that attempting to provide helpful and accurate 
error message is challenging...

--
components: Parser
messages: 399837
nosy: aroberge, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: SyntaxError: trailing comma not allowed ... misleading
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com