Bug 902401
Summary: | importing Gtk crashes the app on headless system | ||||||
---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Martin Sivák <msivak> | ||||
Component: | gtk3 | Assignee: | Matthias Clasen <mclasen> | ||||
Status: | CLOSED CURRENTRELEASE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||
Severity: | high | Docs Contact: | |||||
Priority: | unspecified | ||||||
Version: | 19 | CC: | ccecchi, mclasen, walters | ||||
Target Milestone: | --- | ||||||
Target Release: | --- | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Whiteboard: | |||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2013-04-08 20:50:39 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: | |||||||
Attachments: |
|
Description
Martin Sivák
2013-01-21 15:24:12 UTC
This has been the traditional behaviour of the gtk python bindings since forever, afaik Well, that may be, but it still is wrong. All the other languages I checked have separate init call. There is even Gtk.init available in Python, it just gets called too early. /usr/lib64/python2.7/site-packages/gi/overrides/Gtk.py contains this: initialized, argv = Gtk.init_check(sys.argv) sys.argv = list(argv) if not initialized: raise RuntimeError("Gtk couldn't be initialized") I understand the reasons for the exception (fallback to different UI mode), but any Python library that has side-effects in it's initialization is really wrong. The reason is we have no equivalent of .h files, but still want to access constants and control when the initialization happens (and if it should happen at all). Moreover, tools like python-nose (unittest launcher) have to import files to take a look at the definitions there, but are not executing anything. Gtk's current behaviour breaks it. Is it possible to modify Gtk so it does not throw an exception when it is imported and (if such compatibility is really needed) tries the init silently again when a library call really needs it? If anybody needs the detection, he should call Gtk.init explicitly and catch the error where it fits his project codebase. The exception used in overrides is way too generic and it is not really nice to have such a generic try/except block around all imports (because it can be somebody else's library that accesses Gtk). And import Gtk can be in lots of files, on the other hand.. Gtk.init is usually a single line in the project. (In reply to comment #2) > > Is it possible to modify Gtk so it does not throw an exception when it is > imported and (if such compatibility is really needed) tries the init > silently again when a library call really needs it? > I don't know, I don't do python. But I am very much convinced that compatibility is needed. Created attachment 685139 [details]
optionally disable the implicit Gtk.init using env variable
This is probably the least intrusive change that will add the behaviour we want without compromising the backward compatibility.
I still think this should be changed properly in the future, but this is the best we can do at this moment.
This should really be filed upstream with pygobject. I tried searching the bugzilla there but couldn't find anything. Making one now. This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle. Changing version to '19'. (As we did not run this process for some time, it could affect also pre-Fedora 19 development cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.) More information and reason for this action is here: https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19 fixed upstream and in 3.8.0 |