patch 8.2.2178: Python 3: non-utf8 character cannot be handled
Problem: Python 3: non-utf8 character cannot be handled.
Solution: Change the string decode. (Björn Linse, closes #1053)
diff --git a/src/if_py_both.h b/src/if_py_both.h
index 7b748b2..2903b0b 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -130,10 +130,11 @@
{
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 @@
}
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 @@
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;