Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-78707-remove
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed May 8, 2024
2 parents 4116250 + 7b0c247 commit 0be21b1
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 28 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,11 @@ on:
push:
branches:
- 'main'
- '3.12'
- '3.11'
- '3.10'
- '3.9'
- '3.8'
- '3.*'
pull_request:
branches:
- 'main'
- '3.12'
- '3.11'
- '3.10'
- '3.9'
- '3.8'
- '3.*'

permissions:
contents: read
Expand Down
3 changes: 3 additions & 0 deletions Doc/library/constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ A small number of constants live in the built-in namespace. They are:
it currently evaluates as true, it will emit a :exc:`DeprecationWarning`.
It will raise a :exc:`TypeError` in a future version of Python.

.. versionchanged:: 3.14
Evaluating :data:`!NotImplemented` in a boolean context now raises a :exc:`TypeError`.


.. index:: single: ...; ellipsis literal
.. data:: Ellipsis
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/email.message.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The :class:`EmailMessage` dictionary-like interface is indexed by the header
names, which must be ASCII values. The values of the dictionary are strings
with some extra methods. Headers are stored and returned in case-preserving
form, but field names are matched case-insensitively. The keys are ordered,
but unlike a real dict, there can be duplicates. Addtional methods are
but unlike a real dict, there can be duplicates. Additional methods are
provided for working with headers that have duplicate keys.

The *payload* is either a string or bytes object, in the case of simple message
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/idle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ Several non-character keys move the cursor and possibly
delete characters. Deletion does not puts text on the clipboard,
but IDLE has an undo list. Wherever this doc discusses keys,
'C' refers to the :kbd:`Control` key on Windows and
Unix and the :kbd:`Command` key on macOS. (And all such dicussions
Unix and the :kbd:`Command` key on macOS. (And all such discussions
assume that the keys have not been re-bound to something else.)

* Arrow keys move the cursor one character or line.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/pyexpat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ XMLParser Objects
by default until a sufficient amount of input is reached.
Due to this delay, registered handlers may — depending of the sizing of
input chunks pushed to Expat — no longer be called right after pushing new
input to the parser. Where immediate feedback and taking over responsiblity
input to the parser. Where immediate feedback and taking over responsibility
of protecting against denial of service from large tokens are both wanted,
calling ``SetReparseDeferralEnabled(False)`` disables reparse deferral
for the current Expat parser instance, temporarily or altogether.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/sys.monitoring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ events, use the expression ``PY_RETURN | PY_START``.

.. monitoring-event:: NO_EVENTS

An alias for ``0`` so users can do explict comparisions like::
An alias for ``0`` so users can do explicit comparisons like::

if get_events(DEBUGGER_ID) == NO_EVENTS:
...
Expand Down
3 changes: 3 additions & 0 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ for more details.
it currently evaluates as true, it will emit a :exc:`DeprecationWarning`.
It will raise a :exc:`TypeError` in a future version of Python.

.. versionchanged:: 3.14
Evaluating :data:`NotImplemented` in a boolean context now raises a :exc:`TypeError`.


Ellipsis
--------
Expand Down
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ Deprecated
Removed
=======

* Using :data:`NotImplemented` in a boolean context will now raise a :exc:`TypeError`.
It had previously raised a :exc:`DeprecationWarning` since Python 3.9. (Contributed
by Jelle Zijlstra in :gh:`118767`.)


pathlib
-------

Expand Down
11 changes: 4 additions & 7 deletions Lib/test/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2130,14 +2130,11 @@ def test_warning_notimplemented(self):
# be evaluated in a boolean context (virtually all such use cases
# are a result of accidental misuse implementing rich comparison
# operations in terms of one another).
# For the time being, it will continue to evaluate as a true value, but
# issue a deprecation warning (with the eventual intent to make it
# a TypeError).
self.assertWarns(DeprecationWarning, bool, NotImplemented)
with self.assertWarns(DeprecationWarning):
self.assertRaises(TypeError, bool, NotImplemented)
with self.assertRaises(TypeError):
self.assertTrue(NotImplemented)
with self.assertWarns(DeprecationWarning):
self.assertFalse(not NotImplemented)
with self.assertRaises(TypeError):
not NotImplemented


class TestBreakpoint(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Using :data:`NotImplemented` in a boolean context now raises
:exc:`TypeError`. Contributed by Jelle Zijlstra in :gh:`118767`.
10 changes: 3 additions & 7 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -2090,13 +2090,9 @@ notimplemented_dealloc(PyObject *notimplemented)
static int
notimplemented_bool(PyObject *v)
{
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"NotImplemented should not be used in a boolean context",
1) < 0)
{
return -1;
}
return 1;
PyErr_SetString(PyExc_TypeError,
"NotImplemented should not be used in a boolean context");
return -1;
}

static PyNumberMethods notimplemented_as_number = {
Expand Down

0 comments on commit 0be21b1

Please sign in to comment.