8000 bpo-35044, doc: Use the :exc: role for the exceptions (GH-10037) · python/cpython@e483f02 · GitHub
[go: up one dir, main page]

Skip to content

Commit e483f02

Browse files
matrixisevstinner
authored andcommitted
bpo-35044, doc: Use the :exc: role for the exceptions (GH-10037)
1 parent ddb961d commit e483f02

17 files changed

+19
-17
lines changed

Doc/c-api/conversion.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The following functions provide locale-independent string to number conversions.
6060
The conversion is independent of the current locale.
6161
6262
If ``endptr`` is ``NULL``, convert the whole string. Raise
63-
ValueError and return ``-1.0`` if the string is not a valid
63+
:exc:`ValueError` and return ``-1.0`` if the string is not a valid
6464
representation of a floating-point number.
6565
6666
If endptr is not ``NULL``, convert as much of the string as

Doc/faq/design.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ Some unacceptable solutions that have been proposed:
528528
mydict = {[1, 2]: '12'}
529529
print(mydict[[1, 2]])
530530

531-
would raise a KeyError exception because the id of the ``[1, 2]`` used in the
531+
would raise a :exc:`KeyError` exception because the id of the ``[1, 2]`` used in the
532532
second line differs from that in the first line. In other words, dictionary
533533
keys should be compared using ``==``, not using :keyword:`is`.
534534

Doc/faq/extending.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ How can I execute arbitrary Python statements from C?
6363
The highest-level function to do this is :c:func:`PyRun_SimpleString` which takes
6464
a single string argument to be executed in the context of the module
6565
``__main__`` and returns ``0`` for success and ``-1`` when an exception occurred
66-
(including ``SyntaxError``). If you want more control, use
66+
(including :exc:`SyntaxError`). If you want more control, use
6767
:c:func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` in
6868
``Python/pythonrun.c``.
6969

Doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ Glossary
200200
``int(3.15)`` converts the floating point number to the integer ``3``, but
201201
in ``3+4.5``, each argument is of a different type (one int, one float),
202202
and both must be converted to the same type before they can be added or it
203-
will raise a ``TypeError``. Without coercion, all arguments of even
203+
will raise a :exc:`TypeError`. Without coercion, all arguments of even
204204
compatible types would have to be normalized to the same value by the
205205
programmer, e.g., ``float(3)+4.5`` rather than just ``3+4.5``.
206206

Doc/library/configparser.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,11 @@ However, there are a few differences that should be taken into account:
401401
because default values cannot be deleted from the section (because technically
402402
they are not there). If they are overridden in the section, deleting causes
403403
the default value to be visible again. Trying to delete a default value
404-
causes a ``KeyError``.
404+
causes a :exc:`KeyError`.
405405

406406
* ``DEFAULTSECT`` cannot be removed from the parser:
407407

408-
* trying to delete it raises ``ValueError``,
408+
* trying to delete it raises :exc:`ValueError`,
409409

410410
* ``parser.clear()`` leaves it intact,
411411

Doc/library/imp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ file paths.
229229
file path. For example, if *path* is
230230
``/foo/bar/__pycache__/baz.cpython-32.pyc`` the returned path would be
231231
``/foo/bar/baz.py``. *path* need not exist, however if it does not conform
232-
to :pep:`3147` format, a ``ValueError`` is raised. If
232+
to :pep:`3147` format, a :exc:`ValueError` is raised. If
233233
:attr:`sys.implementation.cache_tag` is not defined,
234234
:exc:`NotImplementedError` is raised.
235235

Doc/library/importlib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ an :term:`importer`.
14071407
file path. For example, if *path* is
14081408
``/foo/bar/__pycache__/baz.cpython-32.pyc`` the returned path would be
14091409
``/foo/bar/baz.py``. *path* need not exist, however if it does not conform
1410-
to :pep:`3147` or :pep:`488` format, a ``ValueError`` is raised. If
1410+
to :pep:`3147` or :pep:`488` format, a :exc:`ValueError` is raised. If
14111411
:attr:`sys.implementation.cache_tag` is not defined,
14121412
:exc:`NotImplementedError` is raised.
14131413

Doc/library/io.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pipe).
3939

4040
All streams are careful about the type of data you give to them. For example
4141
giving a :class:`str` object to the ``write()`` method of a binary stream
42-
will raise a ``TypeError``. So will giving a :class:`bytes` object to the
42+
will raise a :exc:`TypeError`. So will giving a :class:`bytes` object to the
4343
``write()`` method of a text stream.
4444

4545
.. versionchanged:: 3.3

Doc/library/os.path.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ the :mod:`glob` module.)
325325
Normalize the case of a pathname. On Unix and Mac OS X, this returns the
326326
path unchanged; on case-insensitive filesystems, it converts the path to
327327
lowercase. On Windows, it also converts forward slashes to backward slashes.
328-
Raise a TypeError if the type of *path* is not ``str`` or ``bytes`` (directly
328+
Raise a :exc:`TypeError` if the type of *path* is not ``str`` or ``bytes`` (directly
329329
or indirectly through the :class:`os.PathLike` interface).
330330

331331
.. versionchanged:: 3.6

Doc/library/ssl.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ to speed up repeated connections from the same clients.
19411941
.. note::
19421942
With versions of OpenSSL older than 0.9.8m, it is only possible
19431943
to set options, not to clear them. Attempting to clear an option
1944-
(by resetting the corresponding bits) will raise a ``ValueError``.
1944+
(by resetting the corresponding bits) will raise a :exc:`ValueError`.
19451945

19461946
.. versionchanged:: 3.6
19471947
:attr:`SSLContext.options` returns :class:`Options` flags:

Doc/library/typing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ The module defines the following classes, functions and decorators:
899899
non-``@overload``-decorated definition, while the latter is used at
900900
runtime but should be ignored by a type checker. At runtime, calling
901901
a ``@overload``-decorated function directly will raise
902-
``NotImplementedError``. An example of overload that gives a more
902+
:exc:`NotImplementedError`. An example of overload that gives a more
903903
precise type than can be expressed using a union or a type variable::
904904

905905
@overload

Doc/library/unittest.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ Test cases
11611161
If *delta* is supplied instead of *places* then the difference
11621162
between *first* and *second* must be less or equal to (or greater than) *delta*.
11631163

1164-
Supplying both *delta* and *places* raises a ``TypeError``.
1164+
Supplying both *delta* and *places* raises a :exc:`TypeError`.
11651165

11661166
.. versionchanged:: 3.2
11671167
:meth:`assertAlmostEqual` automatically considers almost equal objects

Doc/tutorial/datastructures.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ objects:
4141
:noindex:
4242

4343
Remove the first item from the list whose value is equal to *x*. It raises a
44-
``ValueError`` if there is no such item.
44+
:exc:`ValueError` if there is no such item.
4545

4646

4747
.. method:: list.pop([i])

Doc/whatsnew/3.5.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ a :term:`__future__` import is necessary::
593593
RuntimeError: generator raised StopIteration
594594

595595
Without a ``__future__`` import, a :exc:`PendingDeprecationWarning` will be
596-
raised whenever a ``StopIteration`` exception is raised inside a generator.
596+
raised whenever a :exc:`StopIteration` exception is raised inside a generator.
597597

598598
.. seealso::
599599

Doc/whatsnew/3.6.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ Some smaller changes made to the core Python language are:
741741

742742
* A ``global`` or ``nonlocal`` statement must now textually appear
743743
before the first use of the affected name in the same scope.
744-
Previously this was a ``SyntaxWarning``.
744+
Previously this was a :exc:`SyntaxWarning`.
745745

746746
* It is now possible to set a :ref:`special method <specialnames>` to
747747
``None`` to indicate that the corresponding operation is not available.

Doc/whatsnew/3.7.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ support the loading of resources from packages. See also
10301030
lacks a spec.
10311031
(Contributed by Garvit Khatri in :issue:`29851`.)
10321032

1033-
:func:`importlib.find_spec` now raises ``ModuleNotFoundError`` instead of
1033+
:func:`importlib.find_spec` now raises :exc:`ModuleNotFoundError` instead of
10341034
:exc:`AttributeError` if the specified parent module is not a package (i.e.
10351035
lacks a ``__path__`` attribute).
10361036
(Contributed by Milan Oberkirch in :issue:`30436`.)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix the documentation with the role ``exc`` for the appropriated exception. Patch by
2+
Stéphane Wirtel

0 commit comments

Comments
 (0)
0