This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Quote-type recognition bug
Type: Stage:
Components: Versions: Python 3.0, Python 2.4, Python 2.3, Python 2.2.3, Python 2.6, Python 2.2.2, Python 2.5, Python 2.2.1, Python 2.2, Python 2.1.2, Python 2.1.1, 3rd party
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: chester, georg.brandl, gvanrossum, lehmannro
Priority: normal Keywords:

Created on 2008-05-11 07:26 by chester, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (7)
msg66607 - (view) Author: Chester (chester) Date: 2008-05-11 07:26
Let's make an intentional syntax error...

>>> print "Testing\"
SyntaxError: EOL while scanning single-quoted string


Please focus on the part of the error message that states "while
scanning single-quoted string". How can Python claim it scanned a
single-quoted string when I fed it with a double-quoted string? That is
a quote type recognition bug in Python which should be fixed.

The error message in this case should, however, be:

SyntaxError: EOL while scanning double-quoted string
msg66608 - (view) Author: Robert Lehmann (lehmannro) * Date: 2008-05-11 07:32
It seems "single-quoted" doesn't mean the actual quotation sign used but
rather how many you used. Compare the multiline triple quote syntax:

$ cat foo.py
"""bar
$ python foo.py
  File "foo.py", line 3

    ^
SyntaxError: EOF while scanning triple-quoted string

This shouldn't read sextuple-quoted string, should it?
msg66609 - (view) Author: Chester (chester) Date: 2008-05-11 07:42
I have e-mailed Guido van Rossum about this. He replied: "Good find.
Please file a bug on bugs.python.org." If that wasn't a bug, he wouldn't
have said that, would he?
msg66612 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-05-11 08:53
This is not a bug in my opinion -- Robert has stated why.

However, since you contacted Guido, let him decide. :)
msg66636 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-05-11 15:03
As the term "single-quoted string" is clearly ambiguous, I propose to
change the error message to just "string" (or perhaps "string literal",
but then you'd have to change the triple-quoted message to
"triple-quoted string literal" too for consistency).
msg66637 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-05-11 15:07
OK, done so in r63068.
msg66642 - (view) Author: Chester (chester) Date: 2008-05-11 16:44
It would be better to say

"End of line while scanning string (<string>, line 1)"

and

"End of f... while scanning multi-line string (<string>, line 1)"


These messages really need to be clear, so putting EOF for example
(which I really don't know what it stands for) is really mind-bending.
History
Date User Action Args
2022-04-11 14:56:34adminsetgithub: 47065
2008-05-11 16:44:37chestersetmessages: + msg66642
2008-05-11 15:07:54georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg66637
2008-05-11 15:03:36gvanrossumsetmessages: + msg66636
2008-05-11 08:53:13georg.brandlsetassignee: gvanrossum
messages: + msg66612
nosy: + gvanrossum, georg.brandl
2008-05-11 07:53:56chestersetversions: + 3rd party
2008-05-11 07:51:47chestersetversions: + Python 2.6, Python 2.5, Python 2.4, Python 2.3, Python 2.2.3, Python 2.2.2, Python 2.2.1, Python 2.2, Python 2.1.2, Python 2.1.1
2008-05-11 07:50:15chestersetversions: + Python 3.0, - Python 2.5
2008-05-11 07:42:19chestersetmessages: + msg66609
2008-05-11 07:32:42lehmannrosetnosy: + lehmannro
messages: + msg66608
2008-05-11 07:26:21chestercreate