From c8084269ceadf181884d2586f9c3b49e4a43bb33 Mon Sep 17 00:00:00 2001 From: Nikolaus Rath Date: Sun, 3 Jan 2021 12:06:35 +0000 Subject: [PATCH] Use ModuleNotFoundError instead of ImportError where appropriate. The new exception was introduced in Python 3.6. --- rst/installation.rst | 2 +- setup.py | 4 ++-- src/s3ql/backends/gs.py | 2 +- src/s3ql/block_cache.py | 2 +- src/s3ql/multi_lock.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rst/installation.rst b/rst/installation.rst index caa709304..ee3c2ffdb 100644 --- a/rst/installation.rst +++ b/rst/installation.rst @@ -58,7 +58,7 @@ that is not the case. To check if a specific module :var:`` is installed, execute :samp:`python3 -c 'import {}; print({}.__version__)'`. This will result in an - `ImportError` if the module is not installed, and will print the + `ModuleNotFoundError` if the module is not installed, and will print the installed version if the module is installed. diff --git a/setup.py b/setup.py index 44cac5224..c00053278 100755 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ try: import setuptools -except ImportError: +except ModuleNotFoundError: raise SystemExit('Setuptools package not found. Please install from ' 'https://pypi.python.org/pypi/setuptools') from setuptools import Extension @@ -54,7 +54,7 @@ def run(self): try: from sphinx.application import Sphinx from docutils.utils import SystemMessage - except ImportError: + except ModuleNotFoundError: raise SystemExit('This command requires Sphinx to be installed.') from None fix_docutils() diff --git a/src/s3ql/backends/gs.py b/src/s3ql/backends/gs.py index 58f08c844..730c16a78 100644 --- a/src/s3ql/backends/gs.py +++ b/src/s3ql/backends/gs.py @@ -34,7 +34,7 @@ try: import google.auth as g_auth -except ImportError: +except ModuleNotFoundError: g_auth = None diff --git a/src/s3ql/block_cache.py b/src/s3ql/block_cache.py index e365c6e6e..f1d8641f4 100644 --- a/src/s3ql/block_cache.py +++ b/src/s3ql/block_cache.py @@ -25,7 +25,7 @@ try: from contextlib import asynccontextmanager -except ImportError: +except ModuleNotFoundError: from async_generator import asynccontextmanager # standard logger for this module diff --git a/src/s3ql/multi_lock.py b/src/s3ql/multi_lock.py index 44cccae4a..2202bc265 100644 --- a/src/s3ql/multi_lock.py +++ b/src/s3ql/multi_lock.py @@ -11,7 +11,7 @@ try: from contextlib import asynccontextmanager -except ImportError: +except ModuleNotFoundError: from async_generator import asynccontextmanager __all__ = [ "MultiLock" ]