ModuleNotFoundError was only introduced in Python 3.6.
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()
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