diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-12-21 16:03:02 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-12-21 16:03:02 +0100 |
commit | 2e2f52a4a0fd560d37a11a7383a4d52b63ca6cfc (patch) | |
tree | c4bde05ee74541b38cfb98052cb4dd64ea91c999 /src/if_py_both.h | |
parent | ef2dff52de52c17fe1bd7c06cbb32d8955901f5a (diff) | |
download | vim-git-2e2f52a4a0fd560d37a11a7383a4d52b63ca6cfc.tar.gz |
patch 8.2.2178: Python 3: non-utf8 character cannot be handledv8.2.2178
Problem: Python 3: non-utf8 character cannot be handled.
Solution: Change the string decode. (Björn Linse, closes #1053)
Diffstat (limited to 'src/if_py_both.h')
-rw-r--r-- | src/if_py_both.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/if_py_both.h b/src/if_py_both.h index 7b748b25e..2903b0ba9 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -130,10 +130,11 @@ StringToChars(PyObject *obj, PyObject **todecref) { PyObject *bytes; - if (!(bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, NULL))) + if (!(bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, + ERRORS_ENCODE_ARG))) return NULL; - if(PyBytes_AsStringAndSize(bytes, (char **) &str, NULL) == -1 + if (PyBytes_AsStringAndSize(bytes, (char **) &str, NULL) == -1 || str == NULL) { Py_DECREF(bytes); @@ -4243,7 +4244,8 @@ StringToLine(PyObject *obj) } else if (PyUnicode_Check(obj)) { - if (!(bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, NULL))) + if (!(bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, + ERRORS_ENCODE_ARG))) return NULL; if (PyBytes_AsStringAndSize(bytes, &str, &len) == -1 @@ -6290,11 +6292,11 @@ _ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookup_dict) PyObject *bytes; char_u *str; - bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, NULL); + bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, ERRORS_ENCODE_ARG); if (bytes == NULL) return -1; - if(PyBytes_AsStringAndSize(bytes, (char **) &str, NULL) == -1) + if (PyBytes_AsStringAndSize(bytes, (char **) &str, NULL) == -1) return -1; if (str == NULL) return -1; |