[pygobject] Fix ctypes.PyDLL construction under Windows
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Fix ctypes.PyDLL construction under Windows
- Date: Fri, 8 Dec 2017 15:58:15 +0000 (UTC)
commit af9ddf322f7cf377996b8fa29906bd4b254dc001
Author: Christoph Reiter <creiter src gnome org>
Date: Fri Dec 8 16:40:33 2017 +0100
Fix ctypes.PyDLL construction under Windows
We require the ctypes.pythonapi interface but can't use the global one
since we have to change it which could potentially break other users
of that interface.
Turns out simply passing None to PyDLL() only works on Unix to load the
CPython library. Instead copy the logic from the ctypes module in the
stdlib.
https://bugzilla.gnome.org/show_bug.cgi?id=622084
gi/_ossighelper.py | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/gi/_ossighelper.py b/gi/_ossighelper.py
index 0fde1bd..2c72134 100644
--- a/gi/_ossighelper.py
+++ b/gi/_ossighelper.py
@@ -139,7 +139,18 @@ def wakeup_on_signal():
_wakeup_fd_is_active = False
-pydll = ctypes.PyDLL(None)
+def create_pythonapi():
+ # We need our own instance of ctypes.pythonapi so we don't modify the
+ # global shared one. Adapted from the ctypes source.
+ if os.name == "nt":
+ return ctypes.PyDLL("python dll", None, sys.dllhandle)
+ elif sys.platform == "cygwin":
+ return ctypes.PyDLL("libpython%d.%d.dll" % sys.version_info[:2])
+ else:
+ return ctypes.PyDLL(None)
+
+
+pydll = create_pythonapi()
PyOS_getsig = pydll.PyOS_getsig
PyOS_getsig.restype = ctypes.c_void_p
PyOS_getsig.argtypes = [ctypes.c_int]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]