From: Sarah Hoffmann Date: Fri, 23 Apr 2021 19:10:19 +0000 (+0200) Subject: use more generic ImportError to check for module X-Git-Tag: v4.0.0~102^2~6 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/3a642d50a4b03e8c0a23cdd1999b5c23d12ce137 use more generic ImportError to check for module ModuleNotFoundError was only introduced in Python 3.6. --- diff --git a/nominatim/db/async_connection.py b/nominatim/db/async_connection.py index c5d6872b..361fe075 100644 --- a/nominatim/db/async_connection.py +++ b/nominatim/db/async_connection.py @@ -14,7 +14,7 @@ from psycopg2.extras import wait_select try: import psycopg2.errors # pylint: disable=no-name-in-module,import-error __has_psycopg2_errors__ = True -except ModuleNotFoundError: +except ImportError: __has_psycopg2_errors__ = False LOG = logging.getLogger() diff --git a/nominatim/tools/replication.py b/nominatim/tools/replication.py index d6e80891..c167a49f 100644 --- a/nominatim/tools/replication.py +++ b/nominatim/tools/replication.py @@ -13,7 +13,7 @@ from nominatim.errors import UsageError try: from osmium.replication.server import ReplicationServer from osmium import WriteHandler -except ModuleNotFoundError as exc: +except ImportError as exc: logging.getLogger().fatal("pyosmium not installed. Replication functions not available.\n" "To install pyosmium via pip: pip3 install osmium") raise UsageError("replication tools not available") from exc