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: SyntaxError with a not-existing offset for unicode code
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.2
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, noam
Priority: normal Keywords:

Created on 2009-11-04 07:04 by noam, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg94879 - (view) Author: Noam Yorav-Raphael (noam) Date: 2009-11-04 07:04
Hello,

This is from the current svn:

> ./python
Python 3.2a0 (py3k:76104, Nov  4 2009, 08:49:44) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> try:
... 	eval("u'שלום'")
... except SyntaxError as e:
... 	e
... 
SyntaxError('invalid syntax', ('<string>', 1, 11, "u'שלום'"))

As you can see, the offset (11) refers to a non-existing character, as
the code contains only 7 characters.

Thanks,
Noam
msg94881 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-11-04 07:17
Apparently the position of the caret is based on the number of bytes in
the line, not on the characters:
>>> [aaa for x in]
  File "<stdin>", line 1
    [aaa for x in]
                 ^
SyntaxError: invalid syntax
>>> [äää for x in]
  File "<stdin>", line 1
    [äää for x in]
                    ^
SyntaxError: invalid syntax

In this example each ä takes two bytes so the caret is 3 extra chars on
the right.
msg94883 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-11-04 07:49
This is actually a duplicate of #2382, so I'm closing it.
#2382 also has some patch.
History
Date User Action Args
2022-04-11 14:56:54adminsetgithub: 51509
2009-11-04 07:49:56ezio.melottisetstatus: open -> closed
resolution: duplicate
messages: + msg94883

stage: resolved
2009-11-04 07:17:51ezio.melottisetpriority: normal
nosy: + ezio.melotti
messages: + msg94881

2009-11-04 07:04:58noamcreate