]> granicus.if.org Git - python/commitdiff
fail more completely by deleting dbhash from sys.modules if bsddb can't be
authorSkip Montanaro <skip@pobox.com>
Thu, 25 Jan 2001 13:47:00 +0000 (13:47 +0000)
committerSkip Montanaro <skip@pobox.com>
Thu, 25 Jan 2001 13:47:00 +0000 (13:47 +0000)
loaded - prevents second import later from succeeding spuriously - mostly of
use in regression tests where the module might get imported more than once

Lib/dbhash.py

index 4abd4f03f1e932689a416b323ce9dfd60d2b1c6a..ad94ed8efa1db35bb3b5bbd67449878d22f1c016 100644 (file)
@@ -1,6 +1,12 @@
 """Provide a (g)dbm-compatible interface to bsdhash.hashopen."""
 
-import bsddb
+import sys
+try:
+    import bsddb
+except ImportError:
+    # prevent a second import of this module from spuriously succeeding
+    del sys.modules[__name__]
+    raise
 
 __all__ = ["error","open"]