Fix BZ 1973946

This commit is contained in:
Thomas Andrejak 2021-08-14 00:52:08 +02:00
parent 800b316a17
commit 4ff57fb387
2 changed files with 59 additions and 1 deletions

View File

@ -0,0 +1,53 @@
Description: Fix PyIOBase_Type
Author: Thomas Andrejak <thomas.andrejak@gmail.com>
Last-Update: 2021-08-13
--- libprelude-5.2.0/bindings/python/libpreludecpp-python.i 2020-09-09 16:30:32.510000000 +0200
+++ libprelude-5.2.0/bindings/python/libpreludecpp-python.i 2021-08-13 23:20:11.672221930 +0200
@@ -163,6 +163,26 @@
$1 = _cb_python_log;
};
+%{
+static PyObject *PyIOBase_TypeObj;
+
+static int init_file_emulator(void)
+{
+ PyObject *io = PyImport_ImportModule("_io");
+ if (io == NULL)
+ return -1;
+ PyIOBase_TypeObj = PyObject_GetAttrString(io, "_IOBase");
+ if (PyIOBase_TypeObj == NULL)
+ return -1;
+ return 0;
+}
+%}
+
+%init %{
+if (init_file_emulator() < 0) {
+ return NULL;
+}
+%}
/* tell swig not to cast void * value */
%typemap(in) void *nocast_file_p %{
@@ -172,8 +192,7 @@
}
#else
- extern PyTypeObject PyIOBase_Type;
- if ( ! PyObject_IsInstance((PyObject *) $input, (PyObject *) &PyIOBase_Type) ) {
+ if ( ! PyObject_IsInstance((PyObject *) $input, PyIOBase_TypeObj) ) {
SWIG_exception_fail(SWIG_RuntimeError, "Argument is not a file object");
}
#endif
@@ -186,8 +205,7 @@
#if PY_VERSION_HEX < 0x03000000
$1 = PyFile_Check((PyObject *) $input);
#else
- extern PyTypeObject PyIOBase_Type;
- $1 = PyObject_IsInstance((PyObject *) $input, (PyObject *) &PyIOBase_Type);
+ $1 = PyObject_IsInstance((PyObject *) $input, PyIOBase_TypeObj);
#endif
%}

View File

@ -7,7 +7,7 @@
Name: libprelude
Version: 5.2.0
Release: 8%{?dist}
Release: 9%{?dist}
Summary: Secure Connections between all Sensors and the Prelude Manager
License: LGPL-2.1+
URL: https://www.prelude-siem.org/
@ -37,6 +37,8 @@ Patch10: libprelude-5.2.0-fix-test_rwlock1.patch
Patch11: libprelude-5.2.0-ruby27.patch
# Remove unneded libraries from libprelude-config --libs (bz#1830473)
Patch12: libprelude-5.2.0-clean_libprelude-config.patch
# #1973946
Patch13: libprelude-5.2.0-fix-PyIOBase_Type.patch
BuildRequires: make
BuildRequires: gcc
BuildRequires: gcc-c++
@ -239,6 +241,9 @@ patch -d %{buildroot}%{_includedir}/libprelude/ -p0 < %SOURCE1
%doc AUTHORS ChangeLog README NEWS
%changelog
* Fri Aug 13 2021 Thomas Andrejak <thomas.andrejak@gmail.com> - 5.2.0-9
- Fix BZ 1973946
* Thu Aug 05 2021 Gwyn Ciesla <gwync@protonmail.com> - 5.2.0-8
- Fix BZ 1908783