linux_xanmod: 5.11.14 -> 5.11.15
[NixPkgs.git] / pkgs / development / libraries / libxml2 / utf8-xmlErrorFuncHandler.patch
blob9f4c99b09341aa006942da9477e095a9f6862d45
1 Index: libxml2-2.9.5/python/libxml.c
2 ===================================================================
3 --- libxml2-2.9.5.orig/python/libxml.c
4 +++ libxml2-2.9.5/python/libxml.c
5 @@ -1620,6 +1620,7 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
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 @@ -1636,10 +1637,16 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
14 str[999] = 0;
15 va_end(ap);
17 +#if PY_MAJOR_VERSION >= 3
18 + /* Ensure the error string doesn't start at UTF8 continuation. */
19 + while (*ptr && (*ptr & 0xc0) == 0x80)
20 + ptr++;
21 +#endif
23 list = PyTuple_New(2);
24 PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt);
25 Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
26 - message = libxml_charPtrConstWrap(str);
27 + message = libxml_charPtrConstWrap(ptr);
28 PyTuple_SetItem(list, 1, message);
29 result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list);
30 Py_XDECREF(list);