Blame SOURCES/libxml2-python3-unicode-errors.patch
|
|
c36c44 |
Index: libxml2-2.9.5/python/libxml.c
|
|
|
c36c44 |
===================================================================
|
|
|
c36c44 |
--- libxml2-2.9.5.orig/python/libxml.c
|
|
|
c36c44 |
+++ libxml2-2.9.5/python/libxml.c
|
|
|
c36c44 |
@@ -1620,6 +1620,7 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
|
|
|
c36c44 |
PyObject *message;
|
|
|
c36c44 |
PyObject *result;
|
|
|
c36c44 |
char str[1000];
|
|
|
c36c44 |
+ unsigned char *ptr = (unsigned char *)str;
|
|
|
c36c44 |
|
|
|
c36c44 |
#ifdef DEBUG_ERROR
|
|
|
c36c44 |
printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg);
|
|
|
c36c44 |
@@ -1636,12 +1637,20 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
|
|
|
c36c44 |
str[999] = 0;
|
|
|
c36c44 |
va_end(ap);
|
|
|
c36c44 |
|
|
|
c36c44 |
+#if PY_MAJOR_VERSION >= 3
|
|
|
c36c44 |
+ /* Ensure the error string doesn't start at UTF8 continuation. */
|
|
|
c36c44 |
+ while (*ptr && (*ptr & 0xc0) == 0x80)
|
|
|
c36c44 |
+ ptr++;
|
|
|
c36c44 |
+#endif
|
|
|
c36c44 |
+
|
|
|
c36c44 |
list = PyTuple_New(2);
|
|
|
c36c44 |
PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt);
|
|
|
c36c44 |
Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
|
|
|
c36c44 |
- message = libxml_charPtrConstWrap(str);
|
|
|
c36c44 |
+ message = libxml_charPtrConstWrap(ptr);
|
|
|
c36c44 |
PyTuple_SetItem(list, 1, message);
|
|
|
c36c44 |
result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list);
|
|
|
c36c44 |
+ /* Forget any errors caused in the error handler. */
|
|
|
c36c44 |
+ PyErr_Clear();
|
|
|
c36c44 |
Py_XDECREF(list);
|
|
|
c36c44 |
Py_XDECREF(result);
|
|
|
c36c44 |
}
|