From 3a642d50a4b03e8c0a23cdd1999b5c23d12ce137 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Fri, 23 Apr 2021 21:10:19 +0200 Subject: [PATCH] use more generic ImportError to check for module ModuleNotFoundError was only introduced in Python 3.6. --- nominatim/db/async_connection.py | 2 +- nominatim/tools/replication.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 -- 2.39.5