Skip to content

Commit e633953

Browse files
committed
If gdbm import fails try python3 fallback
in python3 import gdbm is replaced by import dbm.gnu. So try that import if import gdbm fails.
1 parent 4a2e3e7 commit e633953

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

roundup/backends/back_anydbm.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,16 @@ def opendb(self, name, mode):
340340
try:
341341
dbm = __import__(db_type)
342342
except ImportError:
343-
raise hyperdb.DatabaseError(_("Couldn't open database - the "
344-
"required module '%s' is not available")%db_type)
343+
if db_type == 'gdbm':
344+
try:
345+
dbm = __import__('dbm.gnu')
346+
except ImportError:
347+
raise hyperdb.DatabaseError(_(
348+
"Couldn't open database - the required module '%s' "
349+
"(as dbm.gnu) is not available")%db_type)
350+
else:
351+
raise hyperdb.DatabaseError(_("Couldn't open database - the "
352+
"required module '%s' is not available")%db_type)
345353
if __debug__:
346354
logging.getLogger('roundup.hyperdb.backend').debug(
347355
"opendb %r.open(%r, %r)"%(db_type, path, mode))

0 commit comments

Comments
 (0)