Skip to content

Commit e681ec6

Browse files
committed
fixed backend detection for Python 3
1 parent 8a25b46 commit e681ec6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

roundup/backends/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# Otherwise the error is reraised.
2828
_modules = {
2929
'mysql': ('MySQLdb',),
30-
'postgresql': ('psycopg',),
30+
'postgresql': ('psycopg2',),
3131
'sqlite': ('pysqlite', 'pysqlite2', 'sqlite3', '_sqlite3', 'sqlite'),
3232
}
3333

@@ -49,9 +49,13 @@ def have_backend(name):
4949
get_backend(name)
5050
return 1
5151
except ImportError as e:
52-
for name in _modules.get(name, (name,)):
53-
if str(e).startswith('No module named %s'%name):
54-
return 0
52+
if hasattr(e, 'name'):
53+
modname = e.name
54+
else:
55+
modname = e.args[0][16:] if e.args[0].startswith('No module named ') else None
56+
57+
if modname and (modname in _modules.get(name, (name,))):
58+
return 0
5559
raise
5660
return 0
5761

0 commit comments

Comments
 (0)