[Zodb-checkins] CVS: Zope3/src/zodb/code - module.py:1.18.4.3

Jim Fulton jim at zope.com
Sun Feb 1 10:07:08 EST 2004


Update of /cvs-repository/Zope3/src/zodb/code
In directory cvs.zope.org:/tmp/cvs-serv1425/src/zodb/code

Modified Files:
      Tag: zope3-zodb3-devel-branch
	module.py 
Log Message:
Added some checks to make sure that:

- The module importer wasn't installed twice (which would cause the
  original __import__ to be lost.

- The importer wasn't uninstalled without being installed first.


=== Zope3/src/zodb/code/module.py 1.18.4.2 => 1.18.4.3 ===
--- Zope3/src/zodb/code/module.py:1.18.4.2	Fri Jan 16 10:43:29 2004
+++ Zope3/src/zodb/code/module.py	Sun Feb  1 10:07:07 2004
@@ -219,14 +219,17 @@
     # sys.modules, because each registry could have a different binding
     # for a particular name.
 
-    def __init__(self):
-        self._saved_import = None
+    _saved_import = None
 
     def install(self):
+        if self._saved_import is not None:
+            raise TypeError("Already installed!")
         self._saved_import = __builtin__.__import__
         __builtin__.__import__ = self.__import__
 
     def uninstall(self):
+        if self._saved_import is None:
+            raise TypeError("Not installed!")
         __builtin__.__import__ = self._saved_import
 
     def _import(self, registry, name, parent, fromlist):




More information about the Zodb-checkins mailing list