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.
Created on 2010年11月11日 01:32 by belopolsky, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (7) | |||
|---|---|---|---|
| msg120936 - (view) | Author: Alexander Belopolsky (belopolsky) * (Python committer) | Date: 2010年11月11日 01:32 | |
Can you see the error in the following?
>>> invalid = 5
File "<stdin>", line 1
invalid = 5
^
SyntaxError: invalid character in identifier
The problem is that an invisible space character crept into the identifier:
>>> repr("invalid")
"'inv\\u200balid'"
With full unicode available in most OSes, the potential for errors like this (accidental or as a result of a practical joke) increases. It would be much easier to spot the offending character if ^ marker pointed at the exact location rather than at the end of the identifier.
See also issue #10382.
|
|||
| msg121059 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2010年11月12日 19:17 | |
I see the marker pointing to the space after '=', which is *really* not helpful. If '5' were instead an identifier, one might be really misdirected. So best would be "Invalid char '0xnnnn' at position n in identifier 'something'" +1 to any improvement in SyntaxError reports. |
|||
| msg228006 - (view) | Author: Mark Lawrence (BreamoreBoy) * | Date: 2014年09月30日 21:33 | |
#10382 has been closed in favour of #2382. |
|||
| msg228021 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2014年09月30日 22:47 | |
It looks like the issue was already fixed: haypo@smithers$ ./python Python 3.5.0a0 (default:8e9df3414185, Oct 1 2014, 00:19:36) >>> invalid = 5 File "<stdin>", line 1 invalid = 5 ^ SyntaxError: invalid character in identifier The cursor is now before "=". It's not on the invalid character inside the identifier, but it's better than before ;-) |
|||
| msg228023 - (view) | Author: Alexander Belopolsky (belopolsky) * (Python committer) | Date: 2014年09月30日 23:00 | |
The issue was not fixed. With multiple invisible space characters I can get Python 3.5.0a0 (default:5313b4c0bb6c, Sep 30 2014, 18:55:45) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin >>> invalid = None File "<stdin>", line 1 invalid = None ^ SyntaxError: invalid character in identifier |
|||
| msg228026 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2014年09月30日 23:12 | |
> The issue was not fixed. With multiple invisible space characters I can get Ok. So this issue is a duplicate of the issue #2382. IMO the fix is to use wcswidth(), but see the issue for the long discussion :-/ |
|||
| msg323735 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2018年08月18日 21:30 | |
When testing how IDLE handles the examples (which it does well, see #2382 msg323734), I discovered that while the single invisible char for msg120936 *is* present in the posted text, the multiple invisible chars for msg228023 are not. The following has them before and after the 'a': invalid |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:08 | admin | set | github: 54593 |
| 2018年08月18日 21:30:39 | terry.reedy | set | nosy:
- BreamoreBoy messages: + msg323735 |
| 2014年10月01日 01:56:20 | berker.peksag | set | stage: needs patch -> resolved |
| 2014年09月30日 23:12:39 | vstinner | set | superseder: [Py3k] SyntaxError cursor shifted if multibyte character is in line. resolution: fixed -> duplicate messages: + msg228026 |
| 2014年09月30日 23:00:21 | belopolsky | set | messages: + msg228023 |
| 2014年09月30日 22:47:27 | vstinner | set | status: open -> closed nosy: + vstinner messages: + msg228021 resolution: fixed |
| 2014年09月30日 21:33:44 | BreamoreBoy | set | nosy:
+ BreamoreBoy messages: + msg228006 |
| 2010年11月17日 23:52:02 | pitrou | set | nosy:
+ benjamin.peterson |
| 2010年11月12日 23:52:29 | ezio.melotti | set | nosy:
+ ezio.melotti |
| 2010年11月12日 19:17:42 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg121059 |
| 2010年11月11日 01:37:09 | belopolsky | set | dependencies: + Command line error marker misplaced on unicode entry |
| 2010年11月11日 01:32:53 | belopolsky | create | |