From bb5bfc3ac7a991f608036d2db1369a06dd24a0fa Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Wed, 28 Oct 2020 22:05:57 +0100 Subject: libxml2: add a patch to fix python 3.9 support (From OE-Core rev: 0d0acc5fefc96ee0f0a856f7fa34caf92e03138f) Signed-off-by: Alexander Kanavin Signed-off-by: Richard Purdie --- .../recipes-core/libxml/libxml2/fix-python39.patch | 94 ++++++++++++++++++++++ meta/recipes-core/libxml/libxml2_2.9.10.bb | 1 + 2 files changed, 95 insertions(+) create mode 100644 meta/recipes-core/libxml/libxml2/fix-python39.patch diff --git a/meta/recipes-core/libxml/libxml2/fix-python39.patch b/meta/recipes-core/libxml/libxml2/fix-python39.patch new file mode 100644 index 0000000000..32590f9ddf --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/fix-python39.patch @@ -0,0 +1,94 @@ +From e4fb36841800038c289997432ca547c9bfef9db1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Fri, 28 Feb 2020 12:48:14 +0100 +Subject: [PATCH] Parenthesize Py_Check() in ifs + +In C, if expressions should be parenthesized. +PyLong_Check, PyUnicode_Check etc. happened to expand to a parenthesized +expression before, but that's not API to rely on. + +Since Python 3.9.0a4 it needs to be parenthesized explicitly. + +Fixes https://gitlab.gnome.org/GNOME/libxml2/issues/149 +Upstream-Status: Backport +Signed-off-by: Alexander Kanavin +--- + python/libxml.c | 4 ++-- + python/types.c | 12 ++++++------ + 2 files changed, 8 insertions(+), 8 deletions(-) + +diff --git a/python/libxml.c b/python/libxml.c +index bc676c4e0..81e709f34 100644 +--- a/python/libxml.c ++++ b/python/libxml.c +@@ -294,7 +294,7 @@ xmlPythonFileReadRaw (void * context, char * buffer, int len) { + lenread = PyBytes_Size(ret); + data = PyBytes_AsString(ret); + #ifdef PyUnicode_Check +- } else if PyUnicode_Check (ret) { ++ } else if (PyUnicode_Check (ret)) { + #if PY_VERSION_HEX >= 0x03030000 + Py_ssize_t size; + const char *tmp; +@@ -359,7 +359,7 @@ xmlPythonFileRead (void * context, char * buffer, int len) { + lenread = PyBytes_Size(ret); + data = PyBytes_AsString(ret); + #ifdef PyUnicode_Check +- } else if PyUnicode_Check (ret) { ++ } else if (PyUnicode_Check (ret)) { + #if PY_VERSION_HEX >= 0x03030000 + Py_ssize_t size; + const char *tmp; +diff --git a/python/types.c b/python/types.c +index c2bafeb19..ed284ec74 100644 +--- a/python/types.c ++++ b/python/types.c +@@ -602,16 +602,16 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj) + if (obj == NULL) { + return (NULL); + } +- if PyFloat_Check (obj) { ++ if (PyFloat_Check (obj)) { + ret = xmlXPathNewFloat((double) PyFloat_AS_DOUBLE(obj)); +- } else if PyLong_Check(obj) { ++ } else if (PyLong_Check(obj)) { + #ifdef PyLong_AS_LONG + ret = xmlXPathNewFloat((double) PyLong_AS_LONG(obj)); + #else + ret = xmlXPathNewFloat((double) PyInt_AS_LONG(obj)); + #endif + #ifdef PyBool_Check +- } else if PyBool_Check (obj) { ++ } else if (PyBool_Check (obj)) { + + if (obj == Py_True) { + ret = xmlXPathNewBoolean(1); +@@ -620,14 +620,14 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj) + ret = xmlXPathNewBoolean(0); + } + #endif +- } else if PyBytes_Check (obj) { ++ } else if (PyBytes_Check (obj)) { + xmlChar *str; + + str = xmlStrndup((const xmlChar *) PyBytes_AS_STRING(obj), + PyBytes_GET_SIZE(obj)); + ret = xmlXPathWrapString(str); + #ifdef PyUnicode_Check +- } else if PyUnicode_Check (obj) { ++ } else if (PyUnicode_Check (obj)) { + #if PY_VERSION_HEX >= 0x03030000 + xmlChar *str; + const char *tmp; +@@ -650,7 +650,7 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj) + ret = xmlXPathWrapString(str); + #endif + #endif +- } else if PyList_Check (obj) { ++ } else if (PyList_Check (obj)) { + int i; + PyObject *node; + xmlNodePtr cur; +-- +GitLab + diff --git a/meta/recipes-core/libxml/libxml2_2.9.10.bb b/meta/recipes-core/libxml/libxml2_2.9.10.bb index 90890ffaed..07ae68610c 100644 --- a/meta/recipes-core/libxml/libxml2_2.9.10.bb +++ b/meta/recipes-core/libxml/libxml2_2.9.10.bb @@ -23,6 +23,7 @@ SRC_URI = "http://www.xmlsoft.org/sources/libxml2-${PV}.tar.gz;name=libtar \ file://CVE-2020-7595.patch \ file://CVE-2019-20388.patch \ file://CVE-2020-24977.patch \ + file://fix-python39.patch \ " SRC_URI[libtar.md5sum] = "10942a1dc23137a8aa07f0639cbfece5" -- cgit v1.2.3-54-g00ecf