[3.12] gh-101100: Fix Sphinx warnings in `whatsnew/3.10.rst` (GH-118356) by miss-islington · Pull Request #118367 · python/cpython
When printing :exc:`AttributeError`, :c:func:`PyErr_Display` will offer When printing :exc:`AttributeError`, :c:func:`!PyErr_Display` will offer suggestions of similar attribute names in the object that the exception was raised from:
.. warning:: Notice this won't work if :c:func:`PyErr_Display` is not called to display the error Notice this won't work if :c:func:`!PyErr_Display` is not called to display the error which can happen if some other custom error display function is used. This is a common scenario in some REPLs like IPython.
NameErrors ~~~~~~~~~~
When printing :exc:`NameError` raised by the interpreter, :c:func:`PyErr_Display` When printing :exc:`NameError` raised by the interpreter, :c:func:`!PyErr_Display` will offer suggestions of similar variable names in the function that the exception was raised from:
.. warning:: Notice this won't work if :c:func:`PyErr_Display` is not called to display the error, Notice this won't work if :c:func:`!PyErr_Display` is not called to display the error, which can happen if some other custom error display function is used. This is a common scenario in some REPLs like IPython.
The default encoding of :class:`TextIOWrapper` and :func:`open` is The default encoding of :class:`~io.TextIOWrapper` and :func:`open` is platform and locale dependent. Since UTF-8 is used on most Unix platforms, omitting ``encoding`` option when opening UTF-8 files (e.g. JSON, YAML, TOML, Markdown) is a very common bug. For example::
Now the :mod:`typing` module has a special value :data:`TypeAlias` Now the :mod:`typing` module has a special value :data:`~typing.TypeAlias` which lets you declare type aliases more explicitly::
StrCache: TypeAlias = 'Cache[str]' # a type alias
:data:`TypeGuard` has been added to the :mod:`typing` module to annotate :data:`~typing.TypeGuard` has been added to the :mod:`typing` module to annotate type guard functions and improve information provided to static type checkers during type narrowing. For more information, please see :data:`TypeGuard`\ 's documentation, and :pep:`647`. during type narrowing. For more information, please see :data:`~typing.TypeGuard`\ 's documentation, and :pep:`647`.
(Contributed by Ken Jin and Guido van Rossum in :issue:`43766`. PEP written by Eric Traut.)
Add :class:`AsyncContextDecorator`, for supporting usage of async context managers as decorators. Add :class:`~contextlib.AsyncContextDecorator`, for supporting usage of async context managers as decorators.
curses ------
:class:`Enum` :func:`__repr__` now returns ``enum_name.member_name`` and :func:`__str__` now returns ``member_name``. Stdlib enums available as :class:`~enum.Enum` :func:`~object.__repr__` now returns ``enum_name.member_name`` and :func:`~object.__str__` now returns ``member_name``. Stdlib enums available as module constants have a :func:`repr` of ``module_name.member_name``. (Contributed by Ethan Furman in :issue:`40066`.)
:func:`fileinput.hook_compressed` now returns :class:`TextIOWrapper` object :func:`fileinput.hook_compressed` now returns :class:`~io.TextIOWrapper` object when *mode* is "r" and file is compressed, like uncompressed files. (Contributed by Inada Naoki in :issue:`5758`.)
Added :func:`importlib.metadata.packages_distributions` for resolving top-level Python modules and packages to their :class:`importlib.metadata.Distribution`. Added :ref:`importlib.metadata.packages_distributions() <package-distributions>` for resolving top-level Python modules and packages to their :ref:`importlib.metadata.Distribution <distributions>`.
inspect -------
Subclasses of ``typing.Protocol`` which only have data variables declared will now raise a ``TypeError`` when checked with ``isinstance`` unless they are decorated with :func:`runtime_checkable`. Previously, these checks are decorated with :func:`~typing.runtime_checkable`. Previously, these checks passed silently. Users should decorate their subclasses with the :func:`runtime_checkable` decorator subclasses with the :func:`!runtime_checkable` decorator if they want runtime protocols. (Contributed by Yurii Karabas in :issue:`38908`.)
* :class:`BZ2File` performance is improved by removing internal ``RLock``. This makes :class:`BZ2File` thread unsafe in the face of multiple simultaneous * :class:`~bz2.BZ2File` performance is improved by removing internal ``RLock``. This makes :class:`!BZ2File` thread unsafe in the face of multiple simultaneous readers or writers, just like its equivalent classes in :mod:`gzip` and :mod:`lzma` have always been. (Contributed by Inada Naoki in :issue:`43785`.)
* :meth:`zimport.zipimporter.load_module` has been deprecated in * :meth:`!zimport.zipimporter.load_module` has been deprecated in preference for :meth:`~zipimport.zipimporter.exec_module`. (Contributed by Brett Cannon in :issue:`26131`.)
* :data:`~ssl.OP_NO_SSLv2`, :data:`~ssl.OP_NO_SSLv3`, :data:`~ssl.OP_NO_TLSv1`, :data:`~ssl.OP_NO_TLSv1_1`, :data:`~ssl.OP_NO_TLSv1_2`, and :data:`~ssl.OP_NO_TLSv1_3` are replaced by :attr:`sslSSLContext.minimum_version` and :attr:`sslSSLContext.maximum_version`. * :data:`!OP_NO_SSLv2`, :data:`!OP_NO_SSLv3`, :data:`!OP_NO_TLSv1`, :data:`!OP_NO_TLSv1_1`, :data:`!OP_NO_TLSv1_2`, and :data:`!OP_NO_TLSv1_3` are replaced by :attr:`~ssl.SSLContext.minimum_version` and :attr:`~ssl.SSLContext.maximum_version`.
* :data:`~ssl.PROTOCOL_SSLv2`, :data:`~ssl.PROTOCOL_SSLv3`, :data:`~ssl.PROTOCOL_SSLv23`, :data:`~ssl.PROTOCOL_TLSv1`, :data:`~ssl.PROTOCOL_TLSv1_1`, :data:`~ssl.PROTOCOL_TLSv1_2`, and :const:`~ssl.PROTOCOL_TLS` are deprecated in favor of * :data:`!PROTOCOL_SSLv2`, :data:`!PROTOCOL_SSLv3`, :data:`!PROTOCOL_SSLv23`, :data:`!PROTOCOL_TLSv1`, :data:`!PROTOCOL_TLSv1_1`, :data:`!PROTOCOL_TLSv1_2`, and :const:`!PROTOCOL_TLS` are deprecated in favor of :const:`~ssl.PROTOCOL_TLS_CLIENT` and :const:`~ssl.PROTOCOL_TLS_SERVER`
* :func:`~ssl.wrap_socket` is replaced by :meth:`ssl.SSLContext.wrap_socket` * :func:`!wrap_socket` is replaced by :meth:`ssl.SSLContext.wrap_socket`
* :func:`~ssl.match_hostname` * :func:`!match_hostname`
* :func:`~ssl.RAND_pseudo_bytes`, :func:`~ssl.RAND_egd` * :func:`!RAND_pseudo_bytes`, :func:`!RAND_egd`
* NPN features like :meth:`ssl.SSLSocket.selected_npn_protocol` and :meth:`ssl.SSLContext.set_npn_protocols` are replaced by ALPN.