diff roundup/backends/back_anydbm.py @ 6209:e9d12d516517

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.
author John Rouillard <rouilj@ieee.org>
date Sun, 28 Jun 2020 20:23:36 -0400
parents a701c9c81597
children 6834bb5473da
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py	Sun Jun 28 20:16:26 2020 -0400
+++ b/roundup/backends/back_anydbm.py	Sun Jun 28 20:23:36 2020 -0400
@@ -340,8 +340,16 @@
         try:
             dbm = __import__(db_type)
         except ImportError:
-            raise hyperdb.DatabaseError(_("Couldn't open database - the "
-                "required module '%s' is not available")%db_type)
+            if db_type == 'gdbm':
+                try:
+                    dbm = __import__('dbm.gnu')
+                except ImportError:
+                    raise hyperdb.DatabaseError(_(
+                        "Couldn't open database - the required module '%s' "
+                        "(as dbm.gnu) is not available")%db_type)
+            else:
+                raise hyperdb.DatabaseError(_("Couldn't open database - the "
+                             "required module '%s' is not available")%db_type)
         if __debug__:
             logging.getLogger('roundup.hyperdb.backend').debug(
                 "opendb %r.open(%r, %r)"%(db_type, path, mode))

Roundup Issue Tracker: http://roundup-tracker.org/