Skip to content

Commit a85eeb9

Browse files
nexushoratiopicnixzAA-Turner
authored
gh-129015: Improve disambiguation between NotImplemented and NotImplementedError (#129562)
--------- Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parent 0978465 commit a85eeb9

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

Doc/library/constants.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ A small number of constants live in the built-in namespace. They are:
4646

4747
See :ref:`implementing-the-arithmetic-operations` for examples.
4848

49-
.. note::
49+
.. caution::
5050

51-
``NotImplementedError`` and :data:`!NotImplemented` are not interchangeable,
52-
even though they have similar names and purposes.
53-
See :exc:`NotImplementedError` for details on when to use it.
51+
:data:`!NotImplemented` and :exc:`!NotImplementedError` are not
52+
interchangeable. This constant should only be used as described
53+
above; see :exc:`NotImplementedError` for details on correct usage
54+
of the exception.
5455

5556
.. versionchanged:: 3.9
5657
Evaluating :data:`!NotImplemented` in a boolean context was deprecated.

Doc/library/exceptions.rst

+6-4
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,13 @@ The following exceptions are the exceptions that are usually raised.
333333
meant to be supported at all -- in that case either leave the operator /
334334
method undefined or, if a subclass, set it to :data:`None`.
335335

336-
.. note::
336+
.. caution::
337+
338+
:exc:`!NotImplementedError` and :data:`!NotImplemented` are not
339+
interchangeable. This exception should only be used as described
340+
above; see :data:`NotImplemented` for details on correct usage of
341+
the built-in constant.
337342

338-
``NotImplementedError`` and :data:`NotImplemented` are not interchangeable,
339-
even though they have similar names and purposes. See
340-
:data:`!NotImplemented` for details on when to use it.
341343

342344
.. exception:: OSError([arg])
343345
OSError(errno, strerror[, filename[, winerror[, filename2]]])

0 commit comments

Comments
 (0)