comparison 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
comparison
equal deleted inserted replaced
6208:74784dd531c8 6209:e9d12d516517
338 # in Python <3 it anydbm was a little dumb so manually open the 338 # in Python <3 it anydbm was a little dumb so manually open the
339 # database with the correct module 339 # database with the correct module
340 try: 340 try:
341 dbm = __import__(db_type) 341 dbm = __import__(db_type)
342 except ImportError: 342 except ImportError:
343 raise hyperdb.DatabaseError(_("Couldn't open database - the " 343 if db_type == 'gdbm':
344 "required module '%s' is not available")%db_type) 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)
345 if __debug__: 353 if __debug__:
346 logging.getLogger('roundup.hyperdb.backend').debug( 354 logging.getLogger('roundup.hyperdb.backend').debug(
347 "opendb %r.open(%r, %r)"%(db_type, path, mode)) 355 "opendb %r.open(%r, %r)"%(db_type, path, mode))
348 return dbm.open(path, mode) 356 return dbm.open(path, mode)
349 357

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