summaryrefslogtreecommitdiff
path: root/gi/__init__.py
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:42:12 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:42:16 +0900
commit7db802a3275790915ed33b470f58786a362551c6 (patch)
treede7b66f2e6ded30942469c5173eb51241422aa48 /gi/__init__.py
parentfecadc1d4b1cd7bafc93313c1120a4b350e2bced (diff)
downloadpygobject2-7db802a3275790915ed33b470f58786a362551c6.tar.gz
pygobject2-7db802a3275790915ed33b470f58786a362551c6.tar.bz2
pygobject2-7db802a3275790915ed33b470f58786a362551c6.zip
Imported Upstream version 3.13.4
Change-Id: If8453fcd54aeed1d4cec58fcabaf92a68d0efbb5 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi/__init__.py')
-rw-r--r--gi/__init__.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/gi/__init__.py b/gi/__init__.py
index df6843c..fe4abcf 100644
--- a/gi/__init__.py
+++ b/gi/__init__.py
@@ -27,12 +27,17 @@ __path__ = extend_path(__path__, __name__)
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('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".')
+ raise ImportError(_static_binding_error)
+
from . import _gi
from ._gi import _gobject
@@ -50,6 +55,20 @@ version_info = _gobject.pygobject_version[:]
__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(".")))