From 7026023eca07c91b94d21a6f9f982af0aa3a0021 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Sat, 1 Oct 2022 21:26:07 -0500 Subject: [PATCH 1/5] Add/refine cross references to items in other lang changes section --- Doc/whatsnew/3.11.rst | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 0cd281edbe5b17..1e6363af747624 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -423,15 +423,18 @@ detected by checking its tag for a ``-32`` suffix. All releases of Python since 3.5 have included this in their 32-bit builds. +.. _whatsnew311-other-lang-changes: + Other Language Changes ====================== -* Starred expressions can be used in :ref:`for statements`. (See - :issue:`46725` for more details.) +* Starred expressions can be used in :keyword:`for` statements. + (See :issue:`46725` for more details.) -* Asynchronous comprehensions are now allowed inside comprehensions in - asynchronous functions. Outer comprehensions implicitly become - asynchronous. (Contributed by Serhiy Storchaka in :issue:`33346`.) +* Asynchronous :ref:`comprehensions ` are now allowed + inside comprehensions in :ref:`asynchronous functions `. + Outer comprehensions implicitly become asynchronous. + (Contributed by Serhiy Storchaka in :issue:`33346`.) * A :exc:`TypeError` is now raised instead of an :exc:`AttributeError` in :meth:`contextlib.ExitStack.enter_context` and @@ -447,8 +450,8 @@ Other Language Changes (Contributed by Serhiy Storchaka in :issue:`12022`.) * Added :meth:`object.__getstate__` which provides the default - implementation of the ``__getstate__()`` method. :mod:`Copying ` - and :mod:`pickling ` instances of subclasses of builtin types + implementation of the :meth:`!__getstate__` method. :mod:`copy`-ing + and :mod:`pickle`-ing instances of subclasses of builtin types :class:`bytearray`, :class:`set`, :class:`frozenset`, :class:`collections.OrderedDict`, :class:`collections.deque`, :class:`weakref.WeakSet`, and :class:`datetime.tzinfo` now copies and @@ -460,14 +463,14 @@ Other Language Changes the current directory, the script's directory or an empty string. (Contributed by Victor Stinner in :gh:`57684`.) -* A ``"z"`` option was added to the format specification mini-language that +* A ``"z"`` option was added to the :ref:`formatspec` that coerces negative zero to zero after rounding to the format precision. See :pep:`682` for more details. (Contributed by John Belmonte in :gh:`90153`.) -* Bytes are no longer accepted on :attr:`sys.path`. Support broke sometime +* Bytes are no longer accepted on :data:`sys.path`. Support broke sometime between Python 3.2 and 3.6 with no one noticing until after Python 3.10.0 was released. Bringing back support would also be problematic due to - interactions between :option:`-b` and :attr:`sys.path_importer_cache` when + interactions between :option:`-b` and :data:`sys.path_importer_cache` when there is a mixture of strings and bytes keys. (Contributed by Thomas Grainger in :gh:`91181`.) From b0a8a36950f450cad5e73efa2da74f54995ff82d Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Sat, 1 Oct 2022 21:32:31 -0500 Subject: [PATCH 2/5] Unify context manager exception changes into single non-repetitive item --- Doc/whatsnew/3.11.rst | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 1e6363af747624..4b2813ebf897dd 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -437,17 +437,12 @@ Other Language Changes (Contributed by Serhiy Storchaka in :issue:`33346`.) * A :exc:`TypeError` is now raised instead of an :exc:`AttributeError` in - :meth:`contextlib.ExitStack.enter_context` and - :meth:`contextlib.AsyncExitStack.enter_async_context` for objects which do not - support the :term:`context manager` or :term:`asynchronous context manager` - protocols correspondingly. - (Contributed by Serhiy Storchaka in :issue:`44471`.) - -* A :exc:`TypeError` is now raised instead of an :exc:`AttributeError` in - :keyword:`with` and :keyword:`async with` statements for objects which do not - support the :term:`context manager` or :term:`asynchronous context manager` - protocols correspondingly. - (Contributed by Serhiy Storchaka in :issue:`12022`.) + :keyword:`with` statements and :meth:`contextlib.ExitStack.enter_context` + for objects that do not support the :term:`context manager` protocol, + and in :keyword:`async with` statements and + :meth:`contextlib.AsyncExitStack.enter_async_context` + for objects not supporting the :term:`asynchronous context manager` protocol. + (Contributed by Serhiy Storchaka in :issue:`12022` and :issue:`44471`.) * Added :meth:`object.__getstate__` which provides the default implementation of the :meth:`!__getstate__` method. :mod:`copy`-ing From cf21ac89f21aaf59aec60712dafafc05ed9d06f6 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Sat, 1 Oct 2022 22:18:50 -0500 Subject: [PATCH 3/5] More clearly describe the intent and consequences of the -P option --- Doc/whatsnew/3.11.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 4b2813ebf897dd..805e41c9862781 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -453,9 +453,15 @@ Other Language Changes pickles instance attributes implemented as :term:`slots <__slots__>`. (Contributed by Serhiy Storchaka in :issue:`26579`.) -* Add :option:`-P` command line option and :envvar:`PYTHONSAFEPATH` environment - variable to not prepend a potentially unsafe path to :data:`sys.path` such as - the current directory, the script's directory or an empty string. +* Added a :option:`-P` command line option + and a :envvar:`PYTHONSAFEPATH` environment variable, + which disable the automatic prepending to :data:`sys.path` + of the script's directory when running a script, + or the current directory when using :option:`-c` and :option:`-m`. + This ensures only stdlib and installed modules + are picked up by :keyword:`import`, + and avoids unintentionally or maliciously shadowing modules + with those in a local (and typically user-writable) directory. (Contributed by Victor Stinner in :gh:`57684`.) * A ``"z"`` option was added to the :ref:`formatspec` that From 2e458fedb1197375ab22e2c15da5685cc02fd93a Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Sat, 1 Oct 2022 22:19:42 -0500 Subject: [PATCH 4/5] Apply minor clarifications & copyedits to rest of section --- Doc/whatsnew/3.11.rst | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 805e41c9862781..19b880cb9c5e99 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -428,12 +428,12 @@ since 3.5 have included this in their 32-bit builds. Other Language Changes ====================== -* Starred expressions can be used in :keyword:`for` statements. +* Starred unpacking expressions can now be used in :keyword:`for` statements. (See :issue:`46725` for more details.) * Asynchronous :ref:`comprehensions ` are now allowed inside comprehensions in :ref:`asynchronous functions `. - Outer comprehensions implicitly become asynchronous. + Outer comprehensions implicitly become asynchronous in this case. (Contributed by Serhiy Storchaka in :issue:`33346`.) * A :exc:`TypeError` is now raised instead of an :exc:`AttributeError` in @@ -444,7 +444,7 @@ Other Language Changes for objects not supporting the :term:`asynchronous context manager` protocol. (Contributed by Serhiy Storchaka in :issue:`12022` and :issue:`44471`.) -* Added :meth:`object.__getstate__` which provides the default +* Added :meth:`object.__getstate__`, which provides the default implementation of the :meth:`!__getstate__` method. :mod:`copy`-ing and :mod:`pickle`-ing instances of subclasses of builtin types :class:`bytearray`, :class:`set`, :class:`frozenset`, @@ -465,14 +465,15 @@ Other Language Changes (Contributed by Victor Stinner in :gh:`57684`.) * A ``"z"`` option was added to the :ref:`formatspec` that - coerces negative zero to zero after rounding to the format precision. See - :pep:`682` for more details. (Contributed by John Belmonte in :gh:`90153`.) + coerces negative to positive zero after rounding to the format precision. + See :pep:`682` for more details. + (Contributed by John Belmonte in :gh:`90153`.) * Bytes are no longer accepted on :data:`sys.path`. Support broke sometime - between Python 3.2 and 3.6 with no one noticing until after Python 3.10.0 - was released. Bringing back support would also be problematic due to + between Python 3.2 and 3.6, with no one noticing until after Python 3.10.0 + was released. In addition, bringing back support would be problematic due to interactions between :option:`-b` and :data:`sys.path_importer_cache` when - there is a mixture of strings and bytes keys. + there is a mixture of :class:`str` and :class:`bytes` keys. (Contributed by Thomas Grainger in :gh:`91181`.) Other CPython Implementation Changes From ec7eb65163fe3857f5e3874ad2813df67002d30f Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Tue, 4 Oct 2022 17:34:23 -0500 Subject: [PATCH 5/5] Tweak the formatting of module references Co-authored-by: Ezio Melotti --- Doc/whatsnew/3.11.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 19b880cb9c5e99..fc1e665b812e93 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -445,8 +445,8 @@ Other Language Changes (Contributed by Serhiy Storchaka in :issue:`12022` and :issue:`44471`.) * Added :meth:`object.__getstate__`, which provides the default - implementation of the :meth:`!__getstate__` method. :mod:`copy`-ing - and :mod:`pickle`-ing instances of subclasses of builtin types + implementation of the :meth:`!__getstate__` method. :mod:`copy`\ing + and :mod:`pickle`\ing instances of subclasses of builtin types :class:`bytearray`, :class:`set`, :class:`frozenset`, :class:`collections.OrderedDict`, :class:`collections.deque`, :class:`weakref.WeakSet`, and :class:`datetime.tzinfo` now copies and