mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-35712: Make using NotImplemented in a boolean context issue a deprecation warning (GH-13195)
This commit is contained in:
parent
ae75a29435
commit
469325c30e
10 changed files with 64 additions and 12 deletions
|
@ -156,13 +156,18 @@ NotImplemented
|
|||
object is accessed through the built-in name ``NotImplemented``. Numeric methods
|
||||
and rich comparison methods should return this value if they do not implement the
|
||||
operation for the operands provided. (The interpreter will then try the
|
||||
reflected operation, or some other fallback, depending on the operator.) Its
|
||||
truth value is true.
|
||||
reflected operation, or some other fallback, depending on the operator.) It
|
||||
should not be evaluated in a boolean context.
|
||||
|
||||
See
|
||||
:ref:`implementing-the-arithmetic-operations`
|
||||
for more details.
|
||||
|
||||
.. versionchanged:: 3.9
|
||||
Evaluating ``NotImplemented`` in a boolean context is deprecated. While
|
||||
it currently evaluates as true, it will emit a :exc:`DeprecationWarning`.
|
||||
It will raise a :exc:`TypeError` in a future version of Python.
|
||||
|
||||
|
||||
Ellipsis
|
||||
.. index::
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue