python-Twisted/no-pygtkcompat.patch

37 lines
1.6 KiB
Diff

Index: Twisted-22.10.0/src/twisted/internet/gireactor.py
===================================================================
--- Twisted-22.10.0.orig/src/twisted/internet/gireactor.py
+++ Twisted-22.10.0/src/twisted/internet/gireactor.py
@@ -21,20 +21,24 @@ On Python 3, pygobject v3.4 or later is
"""
-import gi.pygtkcompat # type: ignore[import]
from gi.repository import GLib # type: ignore[import]
from twisted.internet import _glibbase
from twisted.internet.error import ReactorAlreadyRunning
from twisted.python import runtime
-# We require a sufficiently new version of pygobject, so always exists:
-_pygtkcompatPresent = True
+try:
+ import gi.pygtkcompat # type: ignore[import]
+except ImportError:
+ pass # This is probably Python 3, with pygtkcompat removed
+else:
+ # We require a sufficiently new version of pygobject, so always exists:
+ _pygtkcompatPresent = True
-# Newer version of gi, so we can try to initialize compatibility layer; if
-# real pygtk was already imported we'll get ImportError at this point
-# rather than segfault, so unconditional import is fine.
-gi.pygtkcompat.enable()
+ # Newer version of gi, so we can try to initialize compatibility layer; if
+ # real pygtk was already imported we'll get ImportError at this point
+ # rather than segfault, so unconditional import is fine.
+ gi.pygtkcompat.enable()
# At this point importing gobject will get you gi version, and importing
# e.g. gtk will either fail in non-segfaulty way or use gi version if user
# does gi.pygtkcompat.enable_gtk(). So, no need to prevent imports of