gh-95913: Copyedit/improve Other Language Changes What's New section (GH-97719)

* Add/refine cross references to items in other lang changes section

* Unify context manager exception changes into single non-repetitive item

* More clearly describe the intent and consequences of the -P option

* Apply minor clarifications & copyedits to rest of section

* Tweak the formatting of module references

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
(cherry picked from commit a77d9dedcd)

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
This commit is contained in:
Miss Islington (bot) 2022-10-04 16:24:50 -07:00 committed by GitHub
parent a685cc0a5e
commit a13b4e8ca6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 35 additions and 30 deletions

View File

@ -427,52 +427,57 @@ See `this message from the Steering Council <https://mail.python.org/archives/li
for more information. for more information.
.. _whatsnew311-other-lang-changes:
Other Language Changes Other Language Changes
====================== ======================
* Starred expressions can be used in :ref:`for statements<for>`. (See * Starred unpacking expressions can now be used in :keyword:`for` statements.
:issue:`46725` for more details.) (See :issue:`46725` for more details.)
* Asynchronous comprehensions are now allowed inside comprehensions in * Asynchronous :ref:`comprehensions <comprehensions>` are now allowed
asynchronous functions. Outer comprehensions implicitly become inside comprehensions in :ref:`asynchronous functions <async def>`.
asynchronous. (Contributed by Serhiy Storchaka in :issue:`33346`.) 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 * A :exc:`TypeError` is now raised instead of an :exc:`AttributeError` in
:meth:`contextlib.ExitStack.enter_context` and :keyword:`with` statements and :meth:`contextlib.ExitStack.enter_context`
:meth:`contextlib.AsyncExitStack.enter_async_context` for objects which do not for objects that do not support the :term:`context manager` protocol,
support the :term:`context manager` or :term:`asynchronous context manager` and in :keyword:`async with` statements and
protocols correspondingly. :meth:`contextlib.AsyncExitStack.enter_async_context`
(Contributed by Serhiy Storchaka in :issue:`44471`.) for objects not supporting the :term:`asynchronous context manager` protocol.
(Contributed by Serhiy Storchaka in :issue:`12022` and :issue:`44471`.)
* A :exc:`TypeError` is now raised instead of an :exc:`AttributeError` in * Added :meth:`object.__getstate__`, which provides the default
:keyword:`with` and :keyword:`async with` statements for objects which do not implementation of the :meth:`!__getstate__` method. :mod:`copy`\ing
support the :term:`context manager` or :term:`asynchronous context manager` and :mod:`pickle`\ing instances of subclasses of builtin types
protocols correspondingly.
(Contributed by Serhiy Storchaka in :issue:`12022`.)
* Added :meth:`object.__getstate__` which provides the default
implementation of the ``__getstate__()`` method. :mod:`Copying <copy>`
and :mod:`pickling <pickle>` instances of subclasses of builtin types
:class:`bytearray`, :class:`set`, :class:`frozenset`, :class:`bytearray`, :class:`set`, :class:`frozenset`,
:class:`collections.OrderedDict`, :class:`collections.deque`, :class:`collections.OrderedDict`, :class:`collections.deque`,
:class:`weakref.WeakSet`, and :class:`datetime.tzinfo` now copies and :class:`weakref.WeakSet`, and :class:`datetime.tzinfo` now copies and
pickles instance attributes implemented as :term:`slots <__slots__>`. pickles instance attributes implemented as :term:`slots <__slots__>`.
(Contributed by Serhiy Storchaka in :issue:`26579`.) (Contributed by Serhiy Storchaka in :issue:`26579`.)
* Add :option:`-P` command line option and :envvar:`PYTHONSAFEPATH` environment * Added a :option:`-P` command line option
variable to not prepend a potentially unsafe path to :data:`sys.path` such as and a :envvar:`PYTHONSAFEPATH` environment variable,
the current directory, the script's directory or an empty string. 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`.) (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 coerces negative to positive zero after rounding to the format precision.
:pep:`682` for more details. (Contributed by John Belmonte in :gh:`90153`.) 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 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 was released. In addition, bringing back support would 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. there is a mixture of :class:`str` and :class:`bytes` keys.
(Contributed by Thomas Grainger in :gh:`91181`.) (Contributed by Thomas Grainger in :gh:`91181`.)
Other CPython Implementation Changes Other CPython Implementation Changes