summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-01-21 20:26:52 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-01-21 20:26:52 (GMT)
commit65fd0592fb3845c17b27c441380553fc22f78812 (patch)
tree514cb4f7fb01bcc581922bee799c3bfbe58a9cd2 /Python
parentf7d2874d3097054e030f0169f5eed92af488acbe (diff)
downloadcpython-65fd0592fb3845c17b27c441380553fc22f78812.zip
cpython-65fd0592fb3845c17b27c441380553fc22f78812.tar.gz
cpython-65fd0592fb3845c17b27c441380553fc22f78812.tar.bz2
Issue #2382: SyntaxError cursor "^" now is written at correct position in most
cases when multibyte characters are in line (before "^"). This still not works correctly with wide East Asian characters.
Diffstat (limited to 'Python')
-rw-r--r--Python/pythonrun.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index e02dbe2..91d56b7 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -2226,6 +2226,7 @@ err_input(perrdetail *err)
PyObject *v, *w, *errtype, *errtext;
PyObject *msg_obj = NULL;
char *msg = NULL;
+ int offset = err->offset;
errtype = PyExc_SyntaxError;
switch (err->error) {
@@ -2310,11 +2311,20 @@ err_input(perrdetail *err)
errtext = Py_None;
Py_INCREF(Py_None);
} else {
- errtext = PyUnicode_DecodeUTF8(err->text, strlen(err->text),
+ errtext = PyUnicode_DecodeUTF8(err->text, err->offset,
"replace");
+ if (errtext != NULL) {
+ Py_ssize_t len = strlen(err->text);
+ offset = (int)PyUnicode_GET_LENGTH(errtext);
+ if (len != err->offset) {
+ Py_DECREF(errtext);
+ errtext = PyUnicode_DecodeUTF8(err->text, len,
+ "replace");
+ }
+ }
}
v = Py_BuildValue("(OiiN)", err->filename,
- err->lineno, err->offset, errtext);
+ err->lineno, offset, errtext);
if (v != NULL) {
if (msg_obj)
w = Py_BuildValue("(OO)", msg_obj, v);