Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 65730a4

Browse files
committed
Delete bsddb from sys.modules if _bsddb cannot be imported.
1 parent d332c08 commit 65730a4

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Lib/bsddb/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@
4343
should use the bsddb3.db module directly.
4444
"""
4545

46-
import _bsddb
46+
try:
47+
import _bsddb
48+
except ImportError:
49+
# Remove ourselves from sys.modules
50+
import sys
51+
del sys.modules[__name__]
52+
raise
53+
4754
# bsddb3 calls it _db
4855
_db = _bsddb
4956
__version__ = _db.__version__

0 commit comments

Comments
 (0)