Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gtk3: remove check for DISPLAY variable #1379

Merged
merged 3 commits into from
Sep 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions src/twisted/internet/gtk3reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,9 @@
Then use twisted.internet APIs as usual.
"""


import os

from twisted.internet import gireactor
from twisted.python import runtime

# Newer versions of gtk3/pygoject raise a RuntimeError, or just break in a
# confusing manner, if the program is not running under X11. We therefore try
# to fail in a more reasonable manner, and check for $DISPLAY as a reasonable
# approximation of availability of X11. This is somewhat over-aggressive,
# since some older versions of gtk3/pygobject do work with missing $DISPLAY,
# but it's too hard to figure out which, so we always require it.
if (runtime.platform.getType() == 'posix' and
not runtime.platform.isMacOSX() and not os.environ.get("DISPLAY")):
raise ImportError(
"Gtk3 requires X11, and no DISPLAY environment variable is set")


class Gtk3Reactor(gireactor.GIReactor):
"""
Expand Down
29 changes: 0 additions & 29 deletions src/twisted/internet/test/test_gireactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""


import os
import sys
from unittest import skipIf
try:
Expand All @@ -27,11 +26,9 @@
gtk3reactor = _gtk3reactor
from gi.repository import Gtk

from twisted.python.runtime import platform
from twisted.internet.error import ReactorAlreadyRunning
from twisted.trial.unittest import TestCase, SkipTest
from twisted.internet.test.reactormixins import ReactorBuilder
from twisted.test.test_twisted import SetAsideModule

# Skip all tests if gi is unavailable:
if gireactor is None:
Expand Down Expand Up @@ -187,29 +184,3 @@ def test_compatibilityLayer(self):
raise SkipTest("This version of gi doesn't include pygtkcompat.")
import gobject
self.assertTrue(gobject.__name__.startswith("gi."))



class Gtk3ReactorTests(TestCase):
"""
Tests for L{gtk3reactor}.
"""

@skipIf(platform.getType() != "posix" or platform.isMacOSX(),
"This test is only relevant when using X11")
def test_requiresDISPLAY(self):
"""
On X11, L{gtk3reactor} is unimportable if the C{DISPLAY} environment
variable is not set.
"""
display = os.environ.get("DISPLAY", None)
if display is not None:
self.addCleanup(os.environ.__setitem__, "DISPLAY", display)
del os.environ["DISPLAY"]
with SetAsideModule("twisted.internet.gtk3reactor"):
exc = self.assertRaises(ImportError,
__import__, "twisted.internet.gtk3reactor")
self.assertEqual(
exc.args[0],
"Gtk3 requires X11, and no DISPLAY environment "
"variable is set")
1 change: 1 addition & 0 deletions src/twisted/newsfragments/9904.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Gtk3 reactor now runs on Wayland-only sessions