You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

77 lines
2.9 KiB

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