From e81e092f4fa49397aada8b6d2748c4592deb43c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Mon, 22 Oct 2018 14:13:58 +0200 Subject: [PATCH 1/7] bpo-35044: Use the :exc: role for the exceptions in the doc --- Doc/c-api/conversion.rst | 2 +- Doc/faq/design.rst | 6 +++--- Doc/faq/extending.rst | 2 +- Doc/glossary.rst | 2 +- Doc/howto/functional.rst | 6 +++--- Doc/library/configparser.rst | 4 ++-- Doc/library/imp.rst | 2 +- Doc/library/importlib.rst | 2 +- Doc/library/io.rst | 2 +- Doc/library/os.path.rst | 2 +- Doc/library/ssl.rst | 2 +- Doc/library/typing.rst | 2 +- Doc/library/unittest.rst | 2 +- Doc/tutorial/datastructures.rst | 2 +- Doc/whatsnew/3.5.rst | 8 ++++---- Doc/whatsnew/3.6.rst | 4 ++-- Doc/whatsnew/3.7.rst | 4 ++-- .../2018-10-22-14-09-58.bpo-35044.qjvNtI.rst | 1 + 18 files changed, 28 insertions(+), 27 deletions(-) create mode 100644 Misc/NEWS.d/next/Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst diff --git a/Doc/c-api/conversion.rst b/Doc/c-api/conversion.rst index 9566d9d792000d..c46722d782a2fb 100644 --- a/Doc/c-api/conversion.rst +++ b/Doc/c-api/conversion.rst @@ -60,7 +60,7 @@ The following functions provide locale-independent string to number conversions. The conversion is independent of the current locale. If ``endptr`` is ``NULL``, convert the whole string. Raise - ValueError and return ``-1.0`` if the string is not a valid + :exc:`ValueError` and return ``-1.0`` if the string is not a valid representation of a floating-point number. If endptr is not ``NULL``, convert as much of the string as diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst index 5e54df61bda9c9..92978ec4d86398 100644 --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -528,9 +528,9 @@ Some unacceptable solutions that have been proposed: mydict = {[1, 2]: '12'} print(mydict[[1, 2]]) - would raise a KeyError exception because the id of the ``[1, 2]`` used in the - second line differs from that in the first line. In other words, dictionary - keys should be compared using ``==``, not using :keyword:`is`. + would raise a :exc:`KeyError` exception because the id of the ``[1, 2]`` used + in the second line differs from that in the first line. In other words, + dictionary keys should be compared using ``==``, not using :keyword:`is`. - Make a copy when using a list as a key. This doesn't work because the list, being a mutable object, could contain a reference to itself, and then the diff --git a/Doc/faq/extending.rst b/Doc/faq/extending.rst index fd04a83df33c3d..b611bb48012af9 100644 --- a/Doc/faq/extending.rst +++ b/Doc/faq/extending.rst @@ -63,7 +63,7 @@ How can I execute arbitrary Python statements from C? The highest-level function to do this is :c:func:`PyRun_SimpleString` which takes a single string argument to be executed in the context of the module ``__main__`` and returns ``0`` for success and ``-1`` when an exception occurred -(including ``SyntaxError``). If you want more control, use +(including :exc:`SyntaxError`). If you want more control, use :c:func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` in ``Python/pythonrun.c``. diff --git a/Doc/glossary.rst b/Doc/glossary.rst index 16fc7f0783c8cb..b8e773741ce7e2 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -200,7 +200,7 @@ Glossary ``int(3.15)`` converts the floating point number to the integer ``3``, but in ``3+4.5``, each argument is of a different type (one int, one float), and both must be converted to the same type before they can be added or it - will raise a ``TypeError``. Without coercion, all arguments of even + will raise a :exc:`TypeError`. Without coercion, all arguments of even compatible types would have to be normalized to the same value by the programmer, e.g., ``float(3)+4.5`` rather than just ``3+4.5``. diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst index 2efe4537e288d6..5a831193e3680f 100644 --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -482,9 +482,9 @@ Here's a sample usage of the ``generate_ints()`` generator: You could equally write ``for i in generate_ints(5)``, or ``a, b, c = generate_ints(3)``. -Inside a generator function, ``return value`` causes ``StopIteration(value)`` -to be raised from the :meth:`~generator.__next__` method. Once this happens, or -the bottom of the function is reached, the procession of values ends and the +Inside a generator function, ``return value`` causes :exc:`StopIteration` to be +raised from the :meth:`~generator.__next__` method. Once this happens, or the +bottom of the function is reached, the procession of values ends and the generator cannot yield any further values. You could achieve the effect of generators manually by writing your own class diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index 0ae466e7d4f823..dcabcc92aaaba2 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -397,11 +397,11 @@ However, there are a few differences that should be taken into account: because default values cannot be deleted from the section (because technically they are not there). If they are overridden in the section, deleting causes the default value to be visible again. Trying to delete a default value - causes a ``KeyError``. + causes a :exc:`KeyError`. * ``DEFAULTSECT`` cannot be removed from the parser: - * trying to delete it raises ``ValueError``, + * trying to delete it raises :exc:`ValueError`, * ``parser.clear()`` leaves it intact, diff --git a/Doc/library/imp.rst b/Doc/library/imp.rst index ccf5f92d1636a3..1bd6f12b915f89 100644 --- a/Doc/library/imp.rst +++ b/Doc/library/imp.rst @@ -229,7 +229,7 @@ file paths. file path. For example, if *path* is ``/foo/bar/__pycache__/baz.cpython-32.pyc`` the returned path would be ``/foo/bar/baz.py``. *path* need not exist, however if it does not conform - to :pep:`3147` format, a ``ValueError`` is raised. If + to :pep:`3147` format, a :exc:`ValueError` is raised. If :attr:`sys.implementation.cache_tag` is not defined, :exc:`NotImplementedError` is raised. diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index 6f4da11989551e..ec91d8d8ef1b61 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -1407,7 +1407,7 @@ an :term:`importer`. file path. For example, if *path* is ``/foo/bar/__pycache__/baz.cpython-32.pyc`` the returned path would be ``/foo/bar/baz.py``. *path* need not exist, however if it does not conform - to :pep:`3147` or :pep:`488` format, a ``ValueError`` is raised. If + to :pep:`3147` or :pep:`488` format, a :exc:`ValueError` is raised. If :attr:`sys.implementation.cache_tag` is not defined, :exc:`NotImplementedError` is raised. diff --git a/Doc/library/io.rst b/Doc/library/io.rst index 98649de7310f0b..2536c37e772b81 100644 --- a/Doc/library/io.rst +++ b/Doc/library/io.rst @@ -39,7 +39,7 @@ pipe). All streams are careful about the type of data you give to them. For example giving a :class:`str` object to the ``write()`` method of a binary stream -will raise a ``TypeError``. So will giving a :class:`bytes` object to the +will raise a :exc:`TypeError`. So will giving a :class:`bytes` object to the ``write()`` method of a text stream. .. versionchanged:: 3.3 diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst index f68fe61c0c2c0f..15007a1bca9285 100644 --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -320,7 +320,7 @@ the :mod:`glob` module.) Normalize the case of a pathname. On Unix and Mac OS X, this returns the path unchanged; on case-insensitive filesystems, it converts the path to lowercase. On Windows, it also converts forward slashes to backward slashes. - Raise a TypeError if the type of *path* is not ``str`` or ``bytes`` (directly + Raise a :exc:`TypeError` if the type of *path* is not ``str`` or ``bytes`` (directly or indirectly through the :class:`os.PathLike` interface). .. versionchanged:: 3.6 diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst index 5b0ef2e1d361cb..4817bba7d4f2d2 100644 --- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -1941,7 +1941,7 @@ to speed up repeated connections from the same clients. .. note:: With versions of OpenSSL older than 0.9.8m, it is only possible to set options, not to clear them. Attempting to clear an option - (by resetting the corresponding bits) will raise a ``ValueError``. + (by resetting the corresponding bits) will raise a :exc:`ValueError`. .. versionchanged:: 3.6 :attr:`SSLContext.options` returns :class:`Options` flags: diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 268adc0c9de5bc..9861da8d7073a5 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -899,7 +899,7 @@ The module defines the following classes, functions and decorators: non-``@overload``-decorated definition, while the latter is used at runtime but should be ignored by a type checker. At runtime, calling a ``@overload``-decorated function directly will raise - ``NotImplementedError``. An example of overload that gives a more + :exc:`NotImplementedError`. An example of overload that gives a more precise type than can be expressed using a union or a type variable:: @overload diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst index 83aee1b0262176..b35a724fc5403a 100644 --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -1161,7 +1161,7 @@ Test cases If *delta* is supplied instead of *places* then the difference between *first* and *second* must be less or equal to (or greater than) *delta*. - Supplying both *delta* and *places* raises a ``TypeError``. + Supplying both *delta* and *places* raises a :exc:`TypeError`. .. versionchanged:: 3.2 :meth:`assertAlmostEqual` automatically considers almost equal objects diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index 95dc0f98ba5134..b291d11595a89b 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -41,7 +41,7 @@ objects: :noindex: Remove the first item from the list whose value is equal to *x*. It raises a - ``ValueError`` if there is no such item. + :exc:`ValueError` if there is no such item. .. method:: list.pop([i]) diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst index 4eddf841dcbec2..49559675b145b3 100644 --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -560,15 +560,15 @@ PEP 479: Change StopIteration handling inside generators The interaction of generators and :exc:`StopIteration` in Python 3.4 and earlier was sometimes surprising, and could conceal obscure bugs. Previously, -``StopIteration`` raised accidentally inside a generator function was +:exc:`StopIteration` raised accidentally inside a generator function was interpreted as the end of the iteration by the loop construct driving the generator. -:pep:`479` changes the behavior of generators: when a ``StopIteration`` +:pep:`479` changes the behavior of generators: when a :exc:`StopIteration` exception is raised inside a generator, it is replaced with a :exc:`RuntimeError` before it exits the generator frame. The main goal of this change is to ease debugging in the situation where an unguarded -:func:`next` call raises ``StopIteration`` and causes the iteration controlled +:func:`next` call raises :exc:`StopIteration` and causes the iteration controlled by the generator to terminate silently. This is particularly pernicious in combination with the ``yield from`` construct. @@ -593,7 +593,7 @@ a :term:`__future__` import is necessary:: RuntimeError: generator raised StopIteration Without a ``__future__`` import, a :exc:`PendingDeprecationWarning` will be -raised whenever a ``StopIteration`` exception is raised inside a generator. +raised whenever a :exc:`StopIteration` exception is raised inside a generator. .. seealso:: diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst index fec7c620d3b83e..095f5d89991784 100644 --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -741,7 +741,7 @@ Some smaller changes made to the core Python language are: * A ``global`` or ``nonlocal`` statement must now textually appear before the first use of the affected name in the same scope. - Previously this was a ``SyntaxWarning``. + Previously this was a :exc:`SyntaxWarning`. * It is now possible to set a :ref:`special method ` to ``None`` to indicate that the corresponding operation is not available. @@ -1200,7 +1200,7 @@ importlib Import now raises the new exception :exc:`ModuleNotFoundError` (subclass of :exc:`ImportError`) when it cannot find a module. Code -that current checks for ``ImportError`` (in try-except) will still work. +that current checks for :exc:`ImportError` `in try-except) will still work. (Contributed by Eric Snow in :issue:`15767`.) :class:`importlib.util.LazyLoader` now calls diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst index ea460b74025e35..b59f2889698519 100644 --- a/Doc/whatsnew/3.7.rst +++ b/Doc/whatsnew/3.7.rst @@ -1030,7 +1030,7 @@ support the loading of resources from packages. See also lacks a spec. (Contributed by Garvit Khatri in :issue:`29851`.) -:func:`importlib.find_spec` now raises ``ModuleNotFoundError`` instead of +:func:`importlib.find_spec` now raises :exc:`ModuleNotFoundError` instead of :exc:`AttributeError` if the specified parent module is not a package (i.e. lacks a ``__path__`` attribute). (Contributed by Milan Oberkirch in :issue:`30436`.) @@ -1393,7 +1393,7 @@ The subprocess module is now more graceful when handling :exc:`KeyboardInterrupt` during :func:`subprocess.call`, :func:`subprocess.run`, or in a :class:`~subprocess.Popen` context manager. It now waits a short amount of time for the child -to exit, before continuing the handling of the ``KeyboardInterrupt`` +to exit, before continuing the handling of the :exc:`KeyboardInterrupt` exception. (Contributed by Gregory P. Smith in :issue:`25942`.) diff --git a/Misc/NEWS.d/next/Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst b/Misc/NEWS.d/next/Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst new file mode 100644 index 00000000000000..6dfd9f3119c8c8 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst @@ -0,0 +1 @@ +Fix the documentation with the role `:exc:` for the appropriated exception. From 89a0373a87c65735357548951f5c2900a372d57c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Mon, 22 Oct 2018 16:21:54 +0200 Subject: [PATCH 2/7] Fix the doc --- Doc/whatsnew/3.6.rst | 2 +- .../next/Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst index 095f5d89991784..42dbe255fbb11d 100644 --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -1200,7 +1200,7 @@ importlib Import now raises the new exception :exc:`ModuleNotFoundError` (subclass of :exc:`ImportError`) when it cannot find a module. Code -that current checks for :exc:`ImportError` `in try-except) will still work. +that current checks for :exc:`ImportError` in try-except) will still work. (Contributed by Eric Snow in :issue:`15767`.) :class:`importlib.util.LazyLoader` now calls diff --git a/Misc/NEWS.d/next/Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst b/Misc/NEWS.d/next/Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst index 6dfd9f3119c8c8..2dc7e3f2a532f4 100644 --- a/Misc/NEWS.d/next/Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst +++ b/Misc/NEWS.d/next/Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst @@ -1 +1 @@ -Fix the documentation with the role `:exc:` for the appropriated exception. +Fix the documentation with the role exc for the appropriated exception. From 1c3c462c458cfe9660f048421775741366ec40dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Mon, 22 Oct 2018 17:29:58 +0200 Subject: [PATCH 3/7] Update with the recommendations of Serhiy --- Doc/howto/functional.rst | 6 +++--- Doc/whatsnew/3.5.rst | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst index 5a831193e3680f..5ad26eb64e3fe5 100644 --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -482,9 +482,9 @@ Here's a sample usage of the ``generate_ints()`` generator: You could equally write ``for i in generate_ints(5)``, or ``a, b, c = generate_ints(3)``. -Inside a generator function, ``return value`` causes :exc:`StopIteration` to be -raised from the :meth:`~generator.__next__` method. Once this happens, or the -bottom of the function is reached, the procession of values ends and the +Inside a generator function, ``return value`` causes ``StopIteration(value)`` to +be raised from the :meth:`~generator.__next__` method. Once this happens, or +the bottom of the function is reached, the procession of values ends and the generator cannot yield any further values. You could achieve the effect of generators manually by writing your own class diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst index 49559675b145b3..b4540ac1dd9028 100644 --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -560,15 +560,15 @@ PEP 479: Change StopIteration handling inside generators The interaction of generators and :exc:`StopIteration` in Python 3.4 and earlier was sometimes surprising, and could conceal obscure bugs. Previously, -:exc:`StopIteration` raised accidentally inside a generator function was +``StopIteration`` raised accidentally inside a generator function was interpreted as the end of the iteration by the loop construct driving the generator. -:pep:`479` changes the behavior of generators: when a :exc:`StopIteration` +:pep:`479` changes the behavior of generators: when a ``StopIteration`` exception is raised inside a generator, it is replaced with a :exc:`RuntimeError` before it exits the generator frame. The main goal of this change is to ease debugging in the situation where an unguarded -:func:`next` call raises :exc:`StopIteration` and causes the iteration controlled +:func:`next` call raises ``StopIteration`` and causes the iteration controlled by the generator to terminate silently. This is particularly pernicious in combination with the ``yield from`` construct. From 7fb33ccd06dc54eab8dbefcf077aa4b70741fa92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Thu, 25 Oct 2018 07:02:59 +0200 Subject: [PATCH 4/7] Update with the recommendations of Victor --- Doc/faq/design.rst | 6 +++--- Doc/howto/functional.rst | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst index 92978ec4d86398..e2d63a0323da66 100644 --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -528,9 +528,9 @@ Some unacceptable solutions that have been proposed: mydict = {[1, 2]: '12'} print(mydict[[1, 2]]) - would raise a :exc:`KeyError` exception because the id of the ``[1, 2]`` used - in the second line differs from that in the first line. In other words, - dictionary keys should be compared using ``==``, not using :keyword:`is`. + would raise a :exc:`KeyError` exception because the id of the ``[1, 2]`` used in the + second line differs from that in the first line. In other words, dictionary + keys should be compared using ``==``, not using :keyword:`is`. - Make a copy when using a list as a key. This doesn't work because the list, being a mutable object, could contain a reference to itself, and then the diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst index 5ad26eb64e3fe5..2efe4537e288d6 100644 --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -482,8 +482,8 @@ Here's a sample usage of the ``generate_ints()`` generator: You could equally write ``for i in generate_ints(5)``, or ``a, b, c = generate_ints(3)``. -Inside a generator function, ``return value`` causes ``StopIteration(value)`` to -be raised from the :meth:`~generator.__next__` method. Once this happens, or +Inside a generator function, ``return value`` causes ``StopIteration(value)`` +to be raised from the :meth:`~generator.__next__` method. Once this happens, or the bottom of the function is reached, the procession of values ends and the generator cannot yield any further values. From 33918b198cee862a4f97c09eb2d730235bf5cf3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Thu, 25 Oct 2018 13:57:58 +0200 Subject: [PATCH 5/7] Use formatting for the role and add Path by... --- .../Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst b/Misc/NEWS.d/next/Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst index 2dc7e3f2a532f4..05e67e51a73adc 100644 --- a/Misc/NEWS.d/next/Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst +++ b/Misc/NEWS.d/next/Documentation/2018-10-22-14-09-58.bpo-35044.qjvNtI.rst @@ -1 +1,2 @@ -Fix the documentation with the role exc for the appropriated exception. +Fix the documentation with the role ``exc`` for the appropriated exception. Patch by +Stéphane Wirtel From 71d425bed4117ad6fa9f2b91bd8cb0a3c51fe459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Thu, 25 Oct 2018 13:58:54 +0200 Subject: [PATCH 6/7] Fix after review --- Doc/whatsnew/3.7.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst index b59f2889698519..d6c95ebf778c6c 100644 --- a/Doc/whatsnew/3.7.rst +++ b/Doc/whatsnew/3.7.rst @@ -1393,7 +1393,7 @@ The subprocess module is now more graceful when handling :exc:`KeyboardInterrupt` during :func:`subprocess.call`, :func:`subprocess.run`, or in a :class:`~subprocess.Popen` context manager. It now waits a short amount of time for the child -to exit, before continuing the handling of the :exc:`KeyboardInterrupt` +to exit, before continuing the handling of the ``KeyboardInterrupt`` exception. (Contributed by Gregory P. Smith in :issue:`25942`.) From 8b69437b23f47d91f98f3867c4e857dc52813eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Thu, 25 Oct 2018 16:16:23 +0200 Subject: [PATCH 7/7] remove the role :exc: --- Doc/whatsnew/3.6.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst index 42dbe255fbb11d..cac007b3cb2db4 100644 --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -1200,7 +1200,7 @@ importlib Import now raises the new exception :exc:`ModuleNotFoundError` (subclass of :exc:`ImportError`) when it cannot find a module. Code -that current checks for :exc:`ImportError` in try-except) will still work. +that current checks for ``ImportError`` (in try-except) will still work. (Contributed by Eric Snow in :issue:`15767`.) :class:`importlib.util.LazyLoader` now calls