[issue42997] Improve error message for missing : before suites

2021-02-02 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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



[issue42997] Improve error message for missing : before suites

2021-02-02 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 58fb156edda1a0e924a38bfed494bd06cb09c9a3 by Pablo Galindo in 
branch 'master':
bpo-42997: Improve error message for missing : before suites (GH-24292)
https://github.com/python/cpython/commit/58fb156edda1a0e924a38bfed494bd06cb09c9a3


--

___
Python tracker 

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



[issue42997] Improve error message for missing : before suites

2021-01-26 Thread Lysandros Nikolaou


Lysandros Nikolaou  added the comment:

> Yeah, but the cut is "absolute" (because of the syntax Error). IIRC the 
> normal cut only affects that rule, no?

Right.

--

___
Python tracker 

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



[issue42997] Improve error message for missing : before suites

2021-01-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> It's basically a positive lookahead with a cut, but the extra feature that it 
> raises a SyntaxError, right?

Yeah, but the cut is "absolute" (because of the syntax Error). IIRC the normal 
cut only affects that rule, no?

--

___
Python tracker 

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



[issue42997] Improve error message for missing : before suites

2021-01-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> See also issue1634034.

The problem with issue1634034 is that is not anymore possible without manual 
changes to the grammar with the PEG parser (or new infrastructure). The new 
parser does not have a defined concept of "i expected this token and now I am 
going to hard fail because is not there", but instead it will backtrack and try 
something else. We also did some work on something similar and we deemed it not 
useful as it was:

bugs.python.org/issue40599

--

___
Python tracker 

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



[issue42997] Improve error message for missing : before suites

2021-01-26 Thread Lysandros Nikolaou


Lysandros Nikolaou  added the comment:

I propose to go with the first approach. I really like that and I can see us 
using it in various place in the future. It's basically a positive lookahead 
with a cut, but the extra feature that it raises a SyntaxError, right?

I'll have a look at the PR now.

--

___
Python tracker 

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



[issue42997] Improve error message for missing : before suites

2021-01-22 Thread Andre Roberge


Change by Andre Roberge :


--
nosy: +aroberge

___
Python tracker 

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



[issue42997] Improve error message for missing : before suites

2021-01-21 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See also issue1634034.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue42997] Improve error message for missing : before suites

2021-01-21 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

PR 24293 implements the second idea (only new rules and no new machinery)

--

___
Python tracker 

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



[issue42997] Improve error message for missing : before suites

2021-01-21 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +23115
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24293

___
Python tracker 

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



[issue42997] Improve error message for missing : before suites

2021-01-21 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
nosy: +gvanrossum

___
Python tracker 

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



[issue42997] Improve error message for missing : before suites

2021-01-21 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

There are several ways to implement this:

In PR24292 I implemented this idea by adding a new element to the grammar: 
'&&'. This allows to hard-expect a token: if the token is not there the parsing 
hard-fails immediately without trying anything else and displays an appropriate 
error message

The other possibility if we think that PR24292 is overkill is manually adding 
an "invalid_wathever" for every possible compound statement option that parses 
the statement with a !':' and then raises appropriately. This option is more 
verbose in the grammar but requires no new machinery.

--
stage: patch review -> 

___
Python tracker 

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



[issue42997] Improve error message for missing : before suites

2021-01-21 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue42997] Improve error message for missing : before suites

2021-01-21 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
nosy: +lys.nikolaou

___
Python tracker 

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



[issue42997] Improve error message for missing : before suites

2021-01-21 Thread Pablo Galindo Salgado


New submission from Pablo Galindo Salgado :

Instead of displaying a generic syntax error:

Python 3.8.6 (default, Oct 10 2020, 18:31:21)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> for x in range
  File "", line 1
for x in range
 ^
SyntaxError: invalid syntax
>>>

we could display:

>>> for x in range
  File "", line 1
for x in range
  ^
SyntaxError: expected ':'

The same idea applies for every suite that has a missing ':'

--
messages: 385463
nosy: pablogsal
priority: normal
severity: normal
status: open
title: Improve error message for missing : before suites
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