[issue44369] Improve syntax error for wrongly closed strings

2021-06-14 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

One problem with that is that the lookahead will move the error indicator to 
some incorrect place if the match fails. For example:

PYTHON3.9

>>> "dfssdfsdfsd" fdsf sdfsdfsd {}
  File "", line 1
"dfssdfsdfsd" fdsf sdfsdfsd {}
  ^
SyntaxError: invalid syntax

with this PR:

>>> "dfssdfsdfsd" fdsf sdfsdfsd {}
  File "", line 1
"dfssdfsdfsd" fdsf sdfsdfsd {}
^
SyntaxError: invalid syntax

We need a solution to this problem first

--

___
Python tracker 

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



[issue44369] Improve syntax error for wrongly closed strings

2021-06-12 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

>From what I can share by my experience, this error happens soo much. So I'd 
>love to see it. 

For a more consistent message with others, maybe it could be something like 
this;

SyntaxError: invalid syntax. Maybe you meant to use a different type of quote

--
nosy: +BTaskaya

___
Python tracker 

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



[issue44369] Improve syntax error for wrongly closed strings

2021-06-09 Thread Andre Roberge


Andre Roberge  added the comment:

I like this. While it would be a bit longer, I'm wondering if the message 
should not read instead as follows:

... Did you use the same quotes here as those enclosing the string?

===

I suspect that errors coming from the use of a single quote, as in:

'Don't do this'

might be just as prevalent if not more so; however, they might be more 
difficult to properly diagnose.

--
nosy: +aroberge

___
Python tracker 

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



[issue44369] Improve syntax error for wrongly closed strings

2021-06-09 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue44369] Improve syntax error for wrongly closed strings

2021-06-09 Thread Pablo Galindo Salgado


New submission from Pablo Galindo Salgado :

Let's asume this string:
"
x = "Cannot recover from "MemoryErrors" while something happnes while "

The line is incorrect because the quotes arround MemoryErrors are the same as 
the string is used, resulting in STRING + expression + STRING.

Currenly we say:

>>> 'Cannot recover from 'MemoryErrors' while '
  File "", line 1
'Cannot recover from 'MemoryErrors' while '
  ^
SyntaxError: invalid syntax

but I think it will be a great improvement if we say:

>>> 'Cannot recover from 'MemoryErrors' while '
  File "", line 1
'Cannot recover from 'MemoryErrors' while '
  
SyntaxError: invalid syntax. Did you use the same quotes here as the string?

Probably the message should be better, but I think this is a good improvement.

--
components: Parser
messages: 395476
nosy: lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Improve syntax error for wrongly closed strings
versions: Python 3.10, Python 3.11

___
Python tracker 

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