]> git.pld-linux.org Git - packages/libxml2.git/blob - libxml2-python3-unicode-errors.patch
up to 2.11.5
[packages/libxml2.git] / libxml2-python3-unicode-errors.patch
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;
10  
11  #ifdef DEBUG_ERROR
12      printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg);
13 @@ -1636,12 +1637,20 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
14             str[999] = 0;
15          va_end(ap);
16  
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
22 +
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 = PyObject_CallObject(libxml_xmlPythonErrorFuncHandler, list);
30 +        /* Forget any errors caused in the error handler. */
31 +        PyErr_Clear();
32          Py_XDECREF(list);
33          Py_XDECREF(result);
34      }
This page took 0.069777 seconds and 3 git commands to generate.