Lines 1-9
Link Here
|
1 |
# Workaround https://bugzilla.gnome.org/show_bug.cgi?id=789714 |
1 |
# Workaround https://bugzilla.gnome.org/show_bug.cgi?id=789714 |
2 |
# Obtained from openSuse / Fedora |
2 |
# Obtained from openSuse / Fedora |
3 |
|
3 |
|
4 |
--- python/libxml.c.orig 2016-06-07 10:04:14 UTC |
4 |
--- python/libxml.c.orig 2023-08-11 20:30:35 UTC |
5 |
+++ python/libxml.c |
5 |
+++ python/libxml.c |
6 |
@@ -1620,6 +1620,7 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU |
6 |
@@ -1606,12 +1606,19 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, |
7 |
PyObject *message; |
7 |
PyObject *message; |
8 |
PyObject *result; |
8 |
PyObject *result; |
9 |
char str[1000]; |
9 |
char str[1000]; |
Lines 11-33
Link Here
|
11 |
|
11 |
|
12 |
#ifdef DEBUG_ERROR |
12 |
#ifdef DEBUG_ERROR |
13 |
printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg); |
13 |
printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg); |
14 |
@@ -1636,12 +1637,20 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU |
14 |
#endif |
15 |
str[999] = 0; |
|
|
16 |
va_end(ap); |
17 |
|
15 |
|
18 |
+#if PY_MAJOR_VERSION >= 3 |
16 |
+#if PY_MAJOR_VERSION >= 3 |
19 |
+ /* Ensure the error string doesn't start at UTF8 continuation. */ |
17 |
+ /* Ensure the error string doesn't start at UTF8 continuation. */ |
20 |
+ while (*ptr && (*ptr & 0xc0) == 0x80) |
18 |
+ while (*ptr && (*ptr & 0xc0) == 0x80) |
21 |
+ ptr++; |
19 |
+ ptr++; |
22 |
+#endif |
20 |
+#endif |
|
|
21 |
|
23 |
+ |
22 |
+ |
|
|
23 |
if (libxml_xmlPythonErrorFuncHandler == NULL) { |
24 |
va_start(ap, msg); |
25 |
vfprintf(stderr, msg, ap); |
26 |
@@ -1625,9 +1632,11 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, |
24 |
list = PyTuple_New(2); |
27 |
list = PyTuple_New(2); |
25 |
PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt); |
28 |
PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt); |
26 |
Py_XINCREF(libxml_xmlPythonErrorFuncCtxt); |
29 |
Py_XINCREF(libxml_xmlPythonErrorFuncCtxt); |
27 |
- message = libxml_charPtrConstWrap(str); |
30 |
- message = libxml_charPtrConstWrap(str); |
28 |
+ message = libxml_charPtrConstWrap(ptr); |
31 |
+ message = libxml_charPtrConstWrap(ptr); |
29 |
PyTuple_SetItem(list, 1, message); |
32 |
PyTuple_SetItem(list, 1, message); |
30 |
result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list); |
33 |
result = PyObject_CallObject(libxml_xmlPythonErrorFuncHandler, list); |
31 |
+ /* Forget any errors caused in the error handler. */ |
34 |
+ /* Forget any errors caused in the error handler. */ |
32 |
+ PyErr_Clear(); |
35 |
+ PyErr_Clear(); |
33 |
Py_XDECREF(list); |
36 |
Py_XDECREF(list); |
34 |
- |
|
|