OCaml 4.14.0 rebuild
[arch-packages.git] / libxml2 / repos / core-x86_64 / libxml2-2.9.8-python3-unicode-errors.patch
blob9b0e43b647a690d80a3f4e3b45dd982969aa65e0
1 diff --git i/python/libxml.c w/python/libxml.c
2 index ef630254..65a51af0 100644
3 --- i/python/libxml.c
4 +++ w/python/libxml.c
5 @@ -1621,28 +1621,37 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg,
6 PyObject *message;
7 PyObject *result;
8 char str[1000];
9 + unsigned char *ptr = (unsigned char *)str;
11 #ifdef DEBUG_ERROR
12 printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg);
13 #endif
16 if (libxml_xmlPythonErrorFuncHandler == NULL) {
17 va_start(ap, msg);
18 vfprintf(stderr, msg, ap);
19 va_end(ap);
20 } else {
21 va_start(ap, msg);
22 if (vsnprintf(str, 999, msg, ap) >= 998)
23 str[999] = 0;
24 va_end(ap);
26 +#if PY_MAJOR_VERSION >= 3
27 + /* Ensure the error string doesn't start at UTF8 continuation. */
28 + while (*ptr && (*ptr & 0xc0) == 0x80)
29 + ptr++;
30 +#endif
32 list = PyTuple_New(2);
33 PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt);
34 Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
35 - message = libxml_charPtrConstWrap(str);
36 + message = libxml_charPtrConstWrap(ptr);
37 PyTuple_SetItem(list, 1, message);
38 result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list);
39 + /* Forget any errors caused in the error handler. */
40 + PyErr_Clear();
41 Py_XDECREF(list);
42 Py_XDECREF(result);