Skip to content

Commit 2efade7

Browse files
committed
ValueError rather than ImportError
1 parent 8a8130f commit 2efade7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

maxminddb/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def open_database(database, mode=MODE_AUTO):
3030
has_extension = maxminddb.extension and hasattr(maxminddb.extension, 'Reader')
3131
if (mode == MODE_AUTO and has_extension) or mode == MODE_MMAP_EXT:
3232
if not has_extension:
33-
raise ImportError(
33+
raise ValueError(
3434
"MODE_MMAP_EXT requires the maxminddb.extension module to be available")
3535
return maxminddb.extension.Reader(database)
3636
elif mode in (MODE_AUTO, MODE_MMAP, MODE_FILE, MODE_MEMORY):

tests/reader_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_ipv6_address_in_ipv4_database(self):
9797
def test_no_extension_exception(self):
9898
real_extension = maxminddb.extension
9999
maxminddb.extension = None
100-
with self.assertRaisesRegex(ImportError, 'MODE_MMAP_EXT requires the maxminddb.extension module to be available'):
100+
with self.assertRaisesRegex(ValueError, 'MODE_MMAP_EXT requires the maxminddb.extension module to be available'):
101101
open_database(
102102
'tests/data/test-data/MaxMind-DB-test-decoder.mmdb', MODE_MMAP_EXT)
103103
maxminddb.extension = real_extension

0 commit comments

Comments
 (0)