Author ncoghlan
Recipients ncoghlan
Date 2016-07-21.11:54:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1469102054.52.0.839726574023.issue27582@psf.upfronthosting.co.za>
In-reply-to
Content
Reporting by Rustom Mody on python-ideas, the SyntaxError caret is confusingly mispositioned when an invalid Unicode codepoint appears as part of a larger sequence of invalid codepoints and/or valid identifier characters:

>>> varname = “d“a”t”apoint
  File "<stdin>", line 1
    varname = “d“a”t”apoint
                          ^
SyntaxError: invalid character in identifier
>>> varname = “d“a”t”apoint.evidence
  File "<stdin>", line 1
    varname = “d“a”t”apoint.evidence
                          ^
SyntaxError: invalid character in identifier
>>> varname = “d“a”t”apoint[evidence]
  File "<stdin>", line 1
    varname = “d“a”t”apoint[evidence]
                          ^
SyntaxError: invalid character in identifier
>>> varname = “d“a”t”apoint(evidence)
  File "<stdin>", line 1
    varname = “d“a”t”apoint(evidence)
                          ^
SyntaxError: invalid character in identifier

If the invalid character is a non-identifiers ASCII character, the error message loses the trailing "in identifier" phrase and points to the correct place:

>>> varname = $d$a$t$apoint
  File "<stdin>", line 1
    varname = $d$a$t$apoint
              ^
SyntaxError: invalid syntax
>>> varname = d$a$t$apoint
  File "<stdin>", line 1
    varname = d$a$t$apoint
               ^
SyntaxError: invalid syntax
>>> varname = ^d$a$t$apoint
  File "<stdin>", line 1
    varname = ^d$a$t$apoint
              ^
SyntaxError: invalid syntax
>>> varname = !d$a$t$apoint
  File "<stdin>", line 1
    varname = !d$a$t$apoint
              ^
SyntaxError: invalid syntax
>>> varname = `d$a$t$apoint
  File "<stdin>", line 1
    varname = `d$a$t$apoint
              ^
SyntaxError: invalid syntax
History
Date User Action Args
2016-07-21 11:54:14ncoghlansetrecipients: + ncoghlan
2016-07-21 11:54:14ncoghlansetmessageid: <1469102054.52.0.839726574023.issue27582@psf.upfronthosting.co.za>
2016-07-21 11:54:14ncoghlanlinkissue27582 messages
2016-07-21 11:54:14ncoghlancreate