]> git.pld-linux.org Git - packages/libxml2.git/blob - libxml2-parenthesize-type-checks.patch
- merged Fedora patches (python3-unicode-errors,fix-relaxed-approach-to-nested-docume...
[packages/libxml2.git] / libxml2-parenthesize-type-checks.patch
1 From edc7b6abb0c125eeb888748c334897f60aab0854 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
3 Date: Fri, 28 Feb 2020 12:48:14 +0100
4 Subject: [PATCH] Parenthesize Py<type>_Check() in ifs
5
6 In C, if expressions should be parenthesized.
7 PyLong_Check, PyUnicode_Check etc. happened to expand to a parenthesized
8 expression before, but that's not API to rely on.
9
10 Since Python 3.9.0a4 it needs to be parenthesized explicitly.
11
12 Fixes https://gitlab.gnome.org/GNOME/libxml2/issues/149
13 ---
14  python/libxml.c |  4 ++--
15  python/types.c  | 12 ++++++------
16  2 files changed, 8 insertions(+), 8 deletions(-)
17
18 diff --git a/python/libxml.c b/python/libxml.c
19 index bc676c4e..81e709f3 100644
20 --- a/python/libxml.c
21 +++ b/python/libxml.c
22 @@ -294,7 +294,7 @@ xmlPythonFileReadRaw (void * context, char * buffer, int len) {
23         lenread = PyBytes_Size(ret);
24         data = PyBytes_AsString(ret);
25  #ifdef PyUnicode_Check
26 -    } else if PyUnicode_Check (ret) {
27 +    } else if (PyUnicode_Check (ret)) {
28  #if PY_VERSION_HEX >= 0x03030000
29          Py_ssize_t size;
30         const char *tmp;
31 @@ -359,7 +359,7 @@ xmlPythonFileRead (void * context, char * buffer, int len) {
32         lenread = PyBytes_Size(ret);
33         data = PyBytes_AsString(ret);
34  #ifdef PyUnicode_Check
35 -    } else if PyUnicode_Check (ret) {
36 +    } else if (PyUnicode_Check (ret)) {
37  #if PY_VERSION_HEX >= 0x03030000
38          Py_ssize_t size;
39         const char *tmp;
40 diff --git a/python/types.c b/python/types.c
41 index c2bafeb1..ed284ec7 100644
42 --- a/python/types.c
43 +++ b/python/types.c
44 @@ -602,16 +602,16 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
45      if (obj == NULL) {
46          return (NULL);
47      }
48 -    if PyFloat_Check (obj) {
49 +    if (PyFloat_Check (obj)) {
50          ret = xmlXPathNewFloat((double) PyFloat_AS_DOUBLE(obj));
51 -    } else if PyLong_Check(obj) {
52 +    } else if (PyLong_Check(obj)) {
53  #ifdef PyLong_AS_LONG
54          ret = xmlXPathNewFloat((double) PyLong_AS_LONG(obj));
55  #else
56          ret = xmlXPathNewFloat((double) PyInt_AS_LONG(obj));
57  #endif
58  #ifdef PyBool_Check
59 -    } else if PyBool_Check (obj) {
60 +    } else if (PyBool_Check (obj)) {
61  
62          if (obj == Py_True) {
63            ret = xmlXPathNewBoolean(1);
64 @@ -620,14 +620,14 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
65            ret = xmlXPathNewBoolean(0);
66          }
67  #endif
68 -    } else if PyBytes_Check (obj) {
69 +    } else if (PyBytes_Check (obj)) {
70          xmlChar *str;
71  
72          str = xmlStrndup((const xmlChar *) PyBytes_AS_STRING(obj),
73                           PyBytes_GET_SIZE(obj));
74          ret = xmlXPathWrapString(str);
75  #ifdef PyUnicode_Check
76 -    } else if PyUnicode_Check (obj) {
77 +    } else if (PyUnicode_Check (obj)) {
78  #if PY_VERSION_HEX >= 0x03030000
79          xmlChar *str;
80         const char *tmp;
81 @@ -650,7 +650,7 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj)
82         ret = xmlXPathWrapString(str);
83  #endif
84  #endif
85 -    } else if PyList_Check (obj) {
86 +    } else if (PyList_Check (obj)) {
87          int i;
88          PyObject *node;
89          xmlNodePtr cur;
90 -- 
91 2.24.1
92
This page took 0.095915 seconds and 3 git commands to generate.