Bug 2123692
Summary: | Importing Gtk in Python without a valid DISPLAY gives error message | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 8 | Reporter: | linma |
Component: | gtk3 | Assignee: | Matthias Clasen <mclasen> |
Status: | CLOSED NOTABUG | QA Contact: | Desktop QE <desktop-qa-list> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | 8.5 | CC: | otte |
Target Milestone: | rc | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2022-10-27 12:20:21 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
As you say, this is not a GTK error message, so there is not really a GTK issue here that could be addressed in this bug. If you want to handle the situation, you can wrap the import statement in a try: except: block, like this import gi try: from gi.repository import Gtk except ImportError: print("no display available") The error message will still happen, unfortunately. The cause of the error message seems to be file libgdk-3.so.0, so I would argue that it indeed is a GTK issue. Further, this error message is only seen on RHEL 8, which uses GTK 3.22. When checking that version, the only hit I get is in gdkdisplay-broadway.c, which seems odd as we are not trying to use broadway. https://github.com/GNOME/gtk/blob/3.22.30/gdk/broadway/gdkdisplay-broadway.c#L112 |
Description of problem: When the display is unset, importing Gtk in Python gives error message. The display is unset by default when ssh:ing to a machine. Our use case is that want to check if Gtk is available without actually using it. Once we confirm that it is available we can start using it, or take another route if it is unavailable. How reproducible: Always shows, given that the display is unset. Steps to Reproduce: Actual results: Import Gtk in Python: [cendio@lab-243 ~]$ DISPLAY= python3 Python 3.6.8 (default, Sep 9 2021, 07:49:02) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import gi >>> gi.require_version("Gtk", "3.0") >>> from gi.repository import Gtk Unable to init server: Could not connect: Connection refused Unable to init server: Could not connect: Connection refused Expected results: Importing Gtk should not give error messages. Additional info: Aside from the error message, everything seem to be working as expected. The errors are not Gtk errors, so it is unclear how they can be silenced. Additionally, this error message is not seen when importing Gtk in Python on RHEL 7.9 or RHEL 9.0.