gh-95913: Copyedit/improve Other Language Changes What's New section (#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>
This commit is contained in:
C.A.M. Gerlach 2022-10-04 18:16:37 -05:00 committed by GitHub
parent 0bf6a617ed
commit a77d9dedcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -427,52 +427,57 @@ See `this message from the Steering Council <https://mail.python.org/archives/li
for more information.
.. _whatsnew311-other-lang-changes:
Other Language Changes
======================
* Starred expressions can be used in :ref:`for statements<for>`. (See
:issue:`46725` for more details.)
* Starred unpacking expressions can now 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 <comprehensions>` are now allowed
inside comprehensions in :ref:`asynchronous functions <async def>`.
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
: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`.)
: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`.)
* 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`.)
* 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
* 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`,
:class:`collections.OrderedDict`, :class:`collections.deque`,
:class:`weakref.WeakSet`, and :class:`datetime.tzinfo` now copies and
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 format specification mini-language 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`.)
* A ``"z"`` option was added to the :ref:`formatspec` that
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 :attr:`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
there is a mixture of strings and bytes keys.
* 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. 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 :class:`str` and :class:`bytes` keys.
(Contributed by Thomas Grainger in :gh:`91181`.)
Other CPython Implementation Changes