mirror of
https://github.com/python/cpython.git
synced 2025-07-08 20:05:28 +00:00
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.
This commit is contained in:
commit
2bd59daf58
4 changed files with 38 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue