archrelease: copy trunk to extra-x86_64
[arch-packages.git] / libxml2 / trunk / libxml2-2.9.8-python3-unicode-errors.patch
blobe87dcdedf88ced34b3a75323d1b8c9698cc5edce
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,12 +1637,20 @@ 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 + /* Forget any errors caused in the error handler. */
31 + PyErr_Clear();
32 Py_XDECREF(list);
33 Py_XDECREF(result);