Blame SOURCES/pygobject-3.22.0-allow-static-module-import.patch

d3680b
--- pygobject-3.22.0/gi/__init__.py.allow-static-module-import	2016-07-06 08:17:26.000000000 +0200
d3680b
+++ pygobject-3.22.0/gi/__init__.py	2017-02-08 16:53:17.446776839 +0100
d3680b
@@ -27,17 +27,12 @@
a8fba1
 import sys
a8fba1
 import os
a8fba1
 import importlib
a8fba1
-import types
a8fba1
-
a8fba1
-_static_binding_error = ('When using gi.repository you must not import static '
a8fba1
-                         'modules like "gobject". Please change all occurrences '
a8fba1
-                         'of "import gobject" to "from gi.repository import GObject". '
a8fba1
-                         'See: https://bugzilla.gnome.org/show_bug.cgi?id=709183')
a8fba1
 
a8fba1
 # we can't have pygobject 2 loaded at the same time we load the internal _gobject
a8fba1
 if 'gobject' in sys.modules:
a8fba1
-    raise ImportError(_static_binding_error)
a8fba1
-
a8fba1
+    raise ImportError('When using gi.repository you must not import static '
a8fba1
+                      'modules like "gobject". Please change all occurrences '
a8fba1
+                      'of "import gobject" to "from gi.repository import GObject".')
a8fba1
 
a8fba1
 from . import _gi
a8fba1
 from ._gi import _gobject
d3680b
@@ -57,20 +52,6 @@
a8fba1
 __version__ = "{0}.{1}.{2}".format(*version_info)
a8fba1
 
a8fba1
 
a8fba1
-class _DummyStaticModule(types.ModuleType):
a8fba1
-    __path__ = None
a8fba1
-
a8fba1
-    def __getattr__(self, name):
a8fba1
-        raise AttributeError(_static_binding_error)
a8fba1
-
a8fba1
-
a8fba1
-sys.modules['glib'] = _DummyStaticModule('glib', _static_binding_error)
a8fba1
-sys.modules['gobject'] = _DummyStaticModule('gobject', _static_binding_error)
a8fba1
-sys.modules['gio'] = _DummyStaticModule('gio', _static_binding_error)
a8fba1
-sys.modules['gtk'] = _DummyStaticModule('gtk', _static_binding_error)
a8fba1
-sys.modules['gtk.gdk'] = _DummyStaticModule('gtk.gdk', _static_binding_error)
a8fba1
-
a8fba1
-
a8fba1
 def check_version(version):
a8fba1
     if isinstance(version, str):
a8fba1
         version_list = tuple(map(int, version.split(".")))
d3680b
--- pygobject-3.22.0/tests/test_import_machinery.py.allow-static-module-import	2016-08-25 16:36:12.000000000 +0200
d3680b
+++ pygobject-3.22.0/tests/test_import_machinery.py	2017-02-08 16:53:17.473776850 +0100
d3680b
@@ -90,30 +90,6 @@
d3680b
         self.assertIn('gi.repository.Gio', sys.modules)
d3680b
         self.assertIn('gi.repository.GIMarshallingTests', sys.modules)
a8fba1
 
a8fba1
-    def test_static_binding_protection(self):
a8fba1
-        # Importing old static bindings once gi has been imported should not
a8fba1
-        # crash but instead give back a dummy module which produces RuntimeErrors
a8fba1
-        # on access.
a8fba1
-        with self.assertRaises(AttributeError):
a8fba1
-            import gobject
a8fba1
-            gobject.anything
a8fba1
-
a8fba1
-        with self.assertRaises(AttributeError):
a8fba1
-            import glib
a8fba1
-            glib.anything
a8fba1
-
a8fba1
-        with self.assertRaises(AttributeError):
a8fba1
-            import gio
a8fba1
-            gio.anything
a8fba1
-
a8fba1
-        with self.assertRaises(AttributeError):
a8fba1
-            import gtk
a8fba1
-            gtk.anything
a8fba1
-
a8fba1
-        with self.assertRaises(AttributeError):
a8fba1
-            import gtk.gdk
a8fba1
-            gtk.gdk.anything
a8fba1
-
a8fba1
 
a8fba1
 class TestImporter(unittest.TestCase):
a8fba1
     def test_invalid_repository_module_name(self):