[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-21 Thread miss-islington


miss-islington  added the comment:


New changeset ae1732d4611ee859c754e7a867b2a4cbb47d0637 by Miss Islington (bot) 
in branch '3.10':
bpo-44180: Fix edge cases in invalid assigment rules in the parser (GH-26283)
https://github.com/python/cpython/commit/ae1732d4611ee859c754e7a867b2a4cbb47d0637


--

___
Python tracker 

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



[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-21 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24896
pull_request: https://github.com/python/cpython/pull/26292

___
Python tracker 

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



[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-21 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +24889
pull_request: https://github.com/python/cpython/pull/26283

___
Python tracker 

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



[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-21 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 07dba474c582e61ca455846da7597d4346324e04 by Miss Islington (bot) 
in branch '3.10':
bpo-44180: Report generic syntax errors in the furthest position reached in the 
first parser pass (GH-26253) (GH-26281)
https://github.com/python/cpython/commit/07dba474c582e61ca455846da7597d4346324e04


--

___
Python tracker 

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



[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-21 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-19 Thread Andre Roberge


Andre Roberge  added the comment:

In the second case, I understand very well that it could have been a set 
literal. In my (limited) experience, I have never seen a set literal containing 
a single element obtained from an == comparison.

Since dict can be built by using keyword arguments, I tend to assume that using 
= in an literal that starts with { is meant to be a dict.

In
>>> ages = {'Alice' = 22}

replacing the equal sign by either ==, :, or a comma would generate no 
SyntaxError.  Clearly (in my mind anyway, and in previous Python versions), the 
"bad token" is the equal sign, and not the string Alice.

Here's what I show with friendly:

==
>>> ages = {'Alice'=22}

Traceback (most recent call last):
  File "", line 1
ages = {'Alice'=22}
   ^
SyntaxError: invalid syntax
>>> why()

It is possible that you used an equal sign = instead of a colon : to assign 
values to keys in a dict before or at the
position indicated by ^.

=
Admitedly, this suggestion could also be wrong - but the focus on this case 
(imo) should be on the "bad token" shown, which should be the equal sign.

--

___
Python tracker 

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



[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-19 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

Hmmm... Then is it possible to add an exception where the error message will 
result in,

SyntaxError: cannot assign to literal here. Maybe you meant ':', "==" or ":=" 
instead of '='?

only if we're dealing with curly braces?

--

___
Python tracker 

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



[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-19 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I don't know, it think is more likely that people are triying to use the "=" as 
a ":" and constructing a literal. Is not a bad error, but I think is not the 
best one

--

___
Python tracker 

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



[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-19 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-19 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

Sorry for the typos.

--

___
Python tracker 

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



[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-19 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

I'm don't the second is a problem at all. What the error message is suggesting 
is perfect since it doesn't know if we're trying to use a set or dict.

--

___
Python tracker 

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



[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-19 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I have an idea of what's causing the first one, but the second I am not sure we 
can detect easily we are in that case. Do you have a suggestion for what to 
place in the second case?

--

___
Python tracker 

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



[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-19 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

The bad token example needs a fix but the second is actually ok because we have 
another type we write within curly braces "{" and there the error is actually 
perfect. Like if we follow the error message, we use

ages = {'Alice'==22}

And we actually get a "set" with the first value as False. Sets behaves 
syntactically like list but have different behaviors of mathematical sets.

--
nosy: +shreyanavigyan

___
Python tracker 

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



[issue44180] SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict literal

2021-05-19 Thread Andre Roberge


New submission from Andre Roberge :

When an equal sign is used instead of a colon in creating a dict literal, 
depending on the context, either the "bad token" is misidentified OR the 
would-be helpful error message is incorrect in this particular case.

1) Example of bad token.
Previously, the = sign was identified correctly:

>>> ages = {'Alice'=22, 'Bob'=23}
  File "", line 1
ages = {'Alice'=22, 'Bob'=23}
   ^
SyntaxError: invalid syntax

With Python 3.10.0b1, the comma is identified as the bad token:

>>> ages = {'Alice'=22, 'Bob'=23}
  File "", line 1
ages = {'Alice'=22, 'Bob'=23}
  ^
SyntaxError: invalid syntax


2) Example of incorrect error message

Previously, we got the traditional and unhelpful "invalid syntax" but with the 
bad token identified correctly:

>>> ages = {'Alice'=22}
  File "", line 1
ages = {'Alice'=22}
   ^
SyntaxError: invalid syntax

With Python 3.10.0b1, we get the following:

>>> ages = {'Alice'=22}
  File "", line 1
ages = {'Alice'=22}
^^^
SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?

I suspect that the ratio (== suggestion correct/ : suggestion correct) would be 
vanishingly small. ;-)

--
components: Parser
messages: 393964
nosy: aroberge, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: SyntaxError misidentified in 3.10.0b1 when = used instead of : in dict 
literal
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