diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2018-04-01 11:17:34 +0200 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-04-01 11:17:34 +0200 |
commit | a7dfb33ae8858b10e0a5f21edaedf0597610574f (patch) | |
tree | 8ba0ea093f12b3e897b7b7dadf0ed1d9512b4fc8 /gi/_ossighelper.py | |
parent | 89a68f503fad697ca190196e5284c01b13af6b37 (diff) | |
download | pygobject-a7dfb33ae8858b10e0a5f21edaedf0597610574f.tar.gz |
ossig: add a C wrapper for PyOS_getsig() instead of accessing the API through ctypes
PyPy doesn't support the ctypes.PyDLL interface.
The ctypes approach was a bit hacky anyway because the interface for loading the
python DLL isn't really documented.
Diffstat (limited to 'gi/_ossighelper.py')
-rw-r--r-- | gi/_ossighelper.py | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/gi/_ossighelper.py b/gi/_ossighelper.py index dc8a8272..5176e97c 100644 --- a/gi/_ossighelper.py +++ b/gi/_ossighelper.py @@ -20,10 +20,11 @@ import os import sys import socket import signal -import ctypes import threading from contextlib import closing, contextmanager +from . import _gi + def ensure_socket_not_inheritable(sock): """Ensures that the socket is not inherited by child processes @@ -139,28 +140,7 @@ def wakeup_on_signal(): _wakeup_fd_is_active = False -def create_pythonapi(): - if not hasattr(ctypes, "PyDLL"): - # PyPy - return - # 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() -if pydll is None: - PyOS_getsig = lambda s: -1 -else: - PyOS_getsig = pydll.PyOS_getsig - PyOS_getsig.restype = ctypes.c_void_p - PyOS_getsig.argtypes = [ctypes.c_int] - +PyOS_getsig = _gi.pyos_getsig # We save the signal pointer so we can detect if glib has changed the # signal handler behind Python's back (GLib.unix_signal_add) |