Bug 1194235 - python3-slip - slip.dbus.service can't be imported
Summary: python3-slip - slip.dbus.service can't be imported
Alias: None
Product: Fedora
Classification: Fedora
Component: python-slip
Version: rawhide
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Nils Philippsen
QA Contact: Fedora Extras Quality Assurance
: 1144673 (view as bug list)
Depends On:
Blocks: 1125209 1251580
TreeView+ depends on / blocked
Reported: 2015-02-19 11:38 UTC by Petr Lautrbach
Modified: 2015-08-07 19:20 UTC (History)
4 users (show)

Fixed In Version: python-slip-0.6.1-1.fc20
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1251580 (view as bug list)
Last Closed: 2015-04-26 12:47:12 UTC
Type: Bug

Attachments (Terms of Use)

Description Petr Lautrbach 2015-02-19 11:38:30 UTC
Description of problem:

$ rpm -q python3-slip

$ python3
Python 3.4.2 (default, Jan 12 2015, 12:13:20) 
[GCC 4.9.2 20150107 (Red Hat 4.9.2-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import slip.dbus.service
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.4/site-packages/slip/dbus/__init__.py", line 8, in <module>
    from . import service
  File "/usr/lib/python3.4/site-packages/slip/dbus/service.py", line 32, in <module>
    from .._wrappers import _gobject as GObject
  File "/usr/lib/python3.4/site-packages/slip/_wrappers/_gobject.py", line 53, in <module>
    setattr(_self, what, getattr(_mod, what))
  File "/usr/lib64/python3.4/site-packages/gi/__init__.py", line 62, in __getattr__
    raise AttributeError(_static_binding_error)
AttributeError: 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". See: https://bugzilla.gnome.org/show_bug.cgi?id=709183

The problem is in slip._wrappers._gobject which tries to abstract between gobject and gi.repository.GObject. The code which detects if to use gi.repository.GObject is probably based on a wrong assumption
that 'gobject' is not listed in sys.modules when gi.repository.GObject is imported. It is apparently not true:

>>> import sys
>>> import gi.repository.GObject
>>> 'gi.repository.GObject' in sys.modules
>>> 'gobject' in sys.modules

The following patch fixes this issue for me:

diff -up /usr/lib/python3.4/site-packages/slip/_wrappers/_gobject.py.orig /usr/lib/python3.4/site-packages/slip/_wrappers/_gobject.py
--- /usr/lib/python3.4/site-packages/slip/_wrappers/_gobject.py.orig    2015-02-19 12:19:48.278330524 +0100
+++ /usr/lib/python3.4/site-packages/slip/_wrappers/_gobject.py 2015-02-19 12:36:31.801840987 +0100
@@ -35,10 +35,10 @@ _self = sys.modules[__name__]
 _mod = None
 while _mod is None:
-    if 'gobject' in sys.modules:
-        _mod = sys.modules['gobject']
-    elif 'gi.repository.GObject' in sys.modules:
+    if 'gi.repository.GObject' in sys.modules:
         _mod = sys.modules['gi.repository.GObject']
+    elif 'gobject' in sys.modules:
+        _mod = sys.modules['gobject']
     # if not yet imported, try to import gobject first, then
     # gi.repository.GObject ...
     if _mod is None:

Comment 1 Robert Kuska 2015-04-02 09:45:11 UTC
Hi, can this be please resolved? It is currently blocking setroubleshoot python3 support.

Comment 2 Fedora Update System 2015-04-16 13:15:11 UTC
python-slip-0.6.1-1.fc22 has been submitted as an update for Fedora 22.

Comment 3 Fedora Update System 2015-04-16 13:15:20 UTC
python-slip-0.6.1-1.fc21 has been submitted as an update for Fedora 21.

Comment 4 Fedora Update System 2015-04-16 13:15:29 UTC
python-slip-0.6.1-1.fc20 has been submitted as an update for Fedora 20.

Comment 5 Fedora Update System 2015-04-17 18:37:18 UTC
Package python-slip-0.6.1-1.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing python-slip-0.6.1-1.fc22'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).

Comment 6 Fedora Update System 2015-04-26 12:47:12 UTC
python-slip-0.6.1-1.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 7 Fedora Update System 2015-05-03 17:23:09 UTC
python-slip-0.6.1-1.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 8 Fedora Update System 2015-05-03 17:24:10 UTC
python-slip-0.6.1-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Nils Philippsen 2015-05-13 18:35:19 UTC
*** Bug 1144673 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.