breaks application when Gtk3 is also used

Bug #885732 reported by Jelmer Vernooij
24
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Python Keyring
Fix Released
High
Unassigned
python-keyring (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

keyring imports the gnomekeyring module, which uses gtk2.

This breaks any Gtk3 applications in which it is loaded.

Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import keyring
>>> from gi.repository import GOBject
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 23, in <module>
    from ._gi import _API, Repository
ImportError: could not import gobject (error was: ImportError('When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".',))

I'm not sure what the best solution is to work around this - it seems pretty hard to determine if the current application is a gtk2 or gtk3 app, especially if keyring is imported before Gtk. It would be nice if there was at least some way of disabling the GNOME backend for keyring, so applications that are aware of this issue can work around it.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

This makes it impossible to do anything that involves launchpadlib in e.g. bzr's Gtk frontends.

Jelmer Vernooij (jelmer)
Changed in python-keyring:
status: New → Triaged
importance: Undecided → High
assignee: nobody → Jelmer Vernooij (jelmer)
status: Triaged → In Progress
Revision history for this message
Dmitry Shachnev (mitya57) wrote :

A workaround is to change importing order:

>>> import gnomekeyring
>>> from gi.repository import Gtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 23, in <module>
    from ._gi import _API, Repository
ImportError: could not import gobject (error was: ImportError('When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".',))

--------

>>> from gi.repository import Gtk
>>> import gnomekeyring
/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject

In this way we don't get crash, only a warning message.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Also, Stef (Gnome Keyring developer) works on a new library (gsecret) that will suport introspection: http://stef.thewalter.net/2011/09/introspecting-certificates.html#c5364051270673968069.

I hope this will be ready for Precise.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

I've already been looking at using the secret service DBus interface, see the bitbucket bug for details.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

@Jelmer: any plans to finish the secret service backend?

Changed in python-keyring (Ubuntu):
status: New → Confirmed
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Yes, it's on my list of things to finish.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

FYI, I use some of your code in my mailsender script:
http://bazaar.launchpad.net/~mitya57/+junk/mailsender/view/head:/secretservice.py

Jelmer Vernooij (jelmer)
Changed in python-keyring:
assignee: Jelmer Vernooij (jelmer) → nobody
Changed in python-keyring:
status: In Progress → Fix Committed
Revision history for this message
Dmitry Shachnev (mitya57) wrote :

This has been fixed in python-keyring 0.9.0.

Changed in python-keyring:
status: Fix Committed → Fix Released
Changed in python-keyring (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.