After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 349026 - reloading gtk fails
reloading gtk fails
Status: RESOLVED FIXED
Product: pygtk
Classification: Bindings
Component: gtk
2.9.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
: 348691 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-07-28 02:06 UTC by Alexander Larsson
Modified: 2006-08-05 15:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
crazy reload hack (779 bytes, patch)
2006-07-28 02:09 UTC, Alexander Larsson
none Details | Review

Description Alexander Larsson 2006-07-28 02:06:57 UTC
importing gtk again if the first import fails (say if DISPLAY is wrong) breaks with:
Traceback (most recent call last):
  • File "/usr/share/system-config-display/xconf.py", line 364 in ?
    reload(gtk)
  • File "/usr/lib64/python2.4/site-packages/gtk-2.0/gtk/__init__.py", line 40 in ?
    from gtk import _gtk
ImportError: cannot import name _gtk

This also happens with:
import gtk
reload(gtk)

While this looks unusual its used in fedora-config-display to first try to connect to the existing display, and if that fails start a new X server to connect to.

The reason this happens is that the above mentioned file deletes gtk._gtk to avoid users accessing it. 

J5 and I came up with a hack that fixes this. Basically you resurrect the gtk._gtk from the sys.modules hashtable the second time.
Comment 1 Alexander Larsson 2006-07-28 02:09:05 UTC
Created attachment 69780 [details] [review]
crazy reload hack
Comment 2 Johan (not receiving bugmail) Dahlin 2006-08-05 15:12:05 UTC
*** Bug 348691 has been marked as a duplicate of this bug. ***
Comment 3 Johan (not receiving bugmail) Dahlin 2006-08-05 15:59:27 UTC
(In reply to comment #1)
> Created an attachment (id=69780) [edit]
> crazy reload hack

I checked in a different (simplified) version of the patch that makes it possible to reload the gtk module:

Checking in ChangeLog;
/cvs/gnome/pygtk/ChangeLog,v  <--  ChangeLog
new revision: 1.1592; previous revision: 1.1591
done
Checking in gtk/__init__.py;
/cvs/gnome/pygtk/gtk/__init__.py,v  <--  __init__.py
new revision: 1.49; previous revision: 1.48
done
Checking in tests/test_api.py;
/cvs/gnome/pygtk/tests/test_api.py,v  <--  test_api.py
new revision: 1.4; previous revision: 1.3
done