Sophie

Sophie

distrib > Mageia > 9 > armv7hl > media > core-release-src > by-pkgid > 0a1482f565198cc7484aaaba97675b18 > files > 1

python-cwiid-3.0.0-6.mga9.src.rpm

From 9d2c8e362f076d8ea5a019fd9a636f5d6afad80b Mon Sep 17 00:00:00 2001
From: Fabio Manganiello <blacklight86@gmail.com>
Date: Tue, 19 Mar 2019 12:31:57 +0100
Subject: [PATCH 1/2] Fixed segfault on Py_DECREF, see
 https://github.com/azzra/python3-wiimote/issues/5 (#6)

---
 python/Wiimote.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/python/Wiimote.c b/python/Wiimote.c
index 2c04016..6d18891 100644
--- a/python/Wiimote.c
+++ b/python/Wiimote.c
@@ -158,7 +158,6 @@ static PyObject *
 	}
 
 	self->wiimote = NULL;
-	Py_INCREF(self->callback = Py_None);
 	self->close_on_dealloc = 0;
 
 	return (PyObject*) self;
@@ -209,6 +208,10 @@ static int Wiimote_init(Wiimote* self, PyObject* args, PyObject *kwds)
 			bdaddr = *BDADDR_ANY;
 		}
 
+        if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 5) {
+            PyEval_InitThreads();
+        }
+
 		Py_BEGIN_ALLOW_THREADS
 		wiimote = cwiid_open(&bdaddr, flags);
 		Py_END_ALLOW_THREADS
@@ -223,6 +226,7 @@ static int Wiimote_init(Wiimote* self, PyObject* args, PyObject *kwds)
 	}
 
 	cwiid_set_data(wiimote, self);
+	Py_INCREF(self->callback = Py_None);
 	self->wiimote = wiimote;
 	return 0;
 }
@@ -326,6 +330,7 @@ static int
 
 	Py_INCREF(NewCallback);
 	Py_DECREF(OldCallback);
+
 	self->callback = NewCallback;
 
 	return 0;
-- 
2.25.0