summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-01-21 20:29:47 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-01-21 20:29:47 (GMT)
commit2bd59daf58431284e13f3e080a52cab032eb792f (patch)
treef84cc2dee484690fc0641850a7f64042583bb033 /Python
parent567b26e882a3a73f37f69390f3a34ec533ff4590 (diff)
parent65fd0592fb3845c17b27c441380553fc22f78812 (diff)
downloadcpython-2bd59daf58431284e13f3e080a52cab032eb792f.zip
cpython-2bd59daf58431284e13f3e080a52cab032eb792f.tar.gz
cpython-2bd59daf58431284e13f3e080a52cab032eb792f.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 97daecc..ff9569b 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -2470,6 +2470,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) {
@@ -2554,11 +2555,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);