summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2006-08-05 15:54:29 +0000
committerJohan Dahlin <johan@src.gnome.org>2006-08-05 15:54:29 +0000
commite461fe82fbb0b955c38bf75485a5b8afc7b7338b (patch)
tree27e87672c228e50624a0f6669805ede3635bc007
parent73fb8e40389b59cbd62699ff4d35b97f5b5b2600 (diff)
downloadpygtk-e461fe82fbb0b955c38bf75485a5b8afc7b7338b.tar.gz
Make it possible to reload the gtk+ module, (#349026, Alexander Larsson)
* gtk/__init__.py (ver): Make it possible to reload the gtk+ module, (#349026, Alexander Larsson) * tests/test_api.py (APITest.testGlade): Add a test
-rw-r--r--ChangeLog5
-rw-r--r--gtk/__init__.py8
-rw-r--r--tests/test_api.py8
3 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index fefe9c12..337b640b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2006-08-05 Johan Dahlin <jdahlin@async.com.br>
+ * gtk/__init__.py (ver): Make it possible to reload the gtk+ module,
+ (#349026, Alexander Larsson)
+
+ * tests/test_api.py (APITest.testGlade): Add a test
+
* gtk/_lazyutils.py (LazyModule.__getattr__): Special case __members__
to dir on the real module, fixes (#349892, John Finlay)
diff --git a/gtk/__init__.py b/gtk/__init__.py
index 608646aa..61fe50df 100644
--- a/gtk/__init__.py
+++ b/gtk/__init__.py
@@ -42,7 +42,11 @@ if ver < (2, 11, 1):
raise ImportError(
"PyGTK requires PyGObject 2.11.1 or higher, but %s was found" % (ver,))
-from gtk import _gtk
+if 'gtk._gtk' in sys.modules:
+ _gtk = sys.modules['gtk._gtk']
+else:
+ from gtk import _gtk
+
import gdk
if ltihooks:
@@ -117,7 +121,7 @@ FALSE = _DeprecatedConstant(False, 'gtk.FALSE', 'False')
gdk.Warning = Warning
# We don't want to export this
-del _Deprecated, _DeprecatedConstant, _gobject, _init, _lazyutils
+del _Deprecated, _DeprecatedConstant, _gobject, _init
# Do this as late as possible, so programs like pyflakes can check
# everything above
diff --git a/tests/test_api.py b/tests/test_api.py
index beb22a46..77984a9e 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -1,3 +1,5 @@
+import os
+import sys
import unittest
from common import gobject, gtk, glade
@@ -26,3 +28,9 @@ class APITest(unittest.TestCase):
def testGlade(self):
self.failUnless(hasattr(glade, 'XML'))
self.failUnless(issubclass(glade.XML, gobject.GObject))
+
+ def testReload(self):
+ # test for #349026
+ del sys.modules['gtk']
+ import gtk
+ reload(gtk)