CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
python3-libxml2: initial import
[ports/opt-arm64.git] / python3-libxml2 / python3.9.patch
1 commit e4fb36841800038c289997432ca547c9bfef9db1
2 Author: Miro HronĨok <miro@hroncok.cz>
3 Date: Fri Feb 28 12:48:14 2020 +0100
4
5 Parenthesize Py<type>_Check() in ifs
6
7 In C, if expressions should be parenthesized.
8 PyLong_Check, PyUnicode_Check etc. happened to expand to a parenthesized
9 expression before, but that's not API to rely on.
10
11 Since Python 3.9.0a4 it needs to be parenthesized explicitly.
12
13 Fixes https://gitlab.gnome.org/GNOME/libxml2/issues/149
14
15 diff --git a/python/libxml.c b/python/libxml.c
16 index bc676c4e..81e709f3 100644
17 --- a/python/libxml.c
18 +++ b/python/libxml.c
19 @@ -294,7 +294,7 @@ xmlPythonFileReadRaw (void * context, char * buffer, int len) {
20 lenread = PyBytes_Size(ret);
21 data = PyBytes_AsString(ret);
22 #ifdef PyUnicode_Check
23 - } else if PyUnicode_Check (ret) {
24 + } else if (PyUnicode_Check (ret)) {
25 #if PY_VERSION_HEX >= 0x03030000
26 Py_ssize_t size;
27 const char *tmp;
28 @@ -359,7 +359,7 @@ xmlPythonFileRead (void * context, char * buffer, int len) {
29 lenread = PyBytes_Size(ret);
30 data = PyBytes_AsString(ret);
31 #ifdef PyUnicode_Check
32 - } else if PyUnicode_Check (ret) {
33 + } else if (PyUnicode_Check (ret)) {
34 #if PY_VERSION_HEX >= 0x03030000
35 Py_ssize_t size;
36 const char *tmp;
37 diff --git a/python/types.c b/python/types.c
38 index c2bafeb1..ed284ec7 100644
39 --- a/python/types.c
40 +++ b/python/types.c
41 @@ -602,16 +602,16 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
42 if (obj == NULL) {
43 return (NULL);
44 }
45 - if PyFloat_Check (obj) {
46 + if (PyFloat_Check (obj)) {
47 ret = xmlXPathNewFloat((double) PyFloat_AS_DOUBLE(obj));
48 - } else if PyLong_Check(obj) {
49 + } else if (PyLong_Check(obj)) {
50 #ifdef PyLong_AS_LONG
51 ret = xmlXPathNewFloat((double) PyLong_AS_LONG(obj));
52 #else
53 ret = xmlXPathNewFloat((double) PyInt_AS_LONG(obj));
54 #endif
55 #ifdef PyBool_Check
56 - } else if PyBool_Check (obj) {
57 + } else if (PyBool_Check (obj)) {
58
59 if (obj == Py_True) {
60 ret = xmlXPathNewBoolean(1);
61 @@ -620,14 +620,14 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
62 ret = xmlXPathNewBoolean(0);
63 }
64 #endif
65 - } else if PyBytes_Check (obj) {
66 + } else if (PyBytes_Check (obj)) {
67 xmlChar *str;
68
69 str = xmlStrndup((const xmlChar *) PyBytes_AS_STRING(obj),
70 PyBytes_GET_SIZE(obj));
71 ret = xmlXPathWrapString(str);
72 #ifdef PyUnicode_Check
73 - } else if PyUnicode_Check (obj) {
74 + } else if (PyUnicode_Check (obj)) {
75 #if PY_VERSION_HEX >= 0x03030000
76 xmlChar *str;
77 const char *tmp;
78 @@ -650,7 +650,7 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
79 ret = xmlXPathWrapString(str);
80 #endif
81 #endif
82 - } else if PyList_Check (obj) {
83 + } else if (PyList_Check (obj)) {
84 int i;
85 PyObject *node;
86 xmlNodePtr cur;