[pygobject] Fix gobject vs. gi.repository warning



commit 745001178fc72be5626c7211366d694f41162987
Author: Martin Pitt <martin pitt ubuntu com>
Date:   Thu Aug 11 15:11:42 2011 +0200

    Fix gobject vs. gi.repository warning
    
    Check the warning earlier and fix the operator, so that it actually works. Also
    update the warning to explain how to fix the problem.

 gi/_gobject/__init__.py |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gi/_gobject/__init__.py b/gi/_gobject/__init__.py
index 4406463..e94e7b8 100644
--- a/gi/_gobject/__init__.py
+++ b/gi/_gobject/__init__.py
@@ -23,6 +23,10 @@
 
 import sys
 
+# 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".')
+
 from .._glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
      io_add_watch, source_remove, child_watch_add, markup_escape_text, \
      get_current_time, filename_display_name, filename_display_basename, \
@@ -47,10 +51,6 @@ from .._glib import SPAWN_LEAVE_DESCRIPTORS_OPEN, SPAWN_DO_NOT_REAP_CHILD, \
 from .constants import *
 from ._gobject import *
 
-# we can't have pygobject 2 loaded at the same time we load the internal _gobject
-if 'gobject' is sys.modules:
-    raise ImportError("The gobject module is already imported.  PyGObject 3 can not be run in the same namespace as PyGObject 2")
-
 _PyGObject_API = _gobject._PyGObject_API
 
 from .propertyhelper import property



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]