Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into pythongh-107265
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 committed Aug 21, 2023
2 parents fb0ab4e + 04f7875 commit 70a29b9
Show file tree
Hide file tree
Showing 13 changed files with 186 additions and 369 deletions.
4 changes: 2 additions & 2 deletions Doc/faq/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,9 @@ exhaustive test suites that exercise every line of code in a module.
An appropriate testing discipline can help build large complex applications in
Python as well as having interface specifications would. In fact, it can be
better because an interface specification cannot test certain properties of a
program. For example, the :meth:`list.append` method is expected to add new elements
program. For example, the :meth:`!list.append` method is expected to add new elements
to the end of some internal list; an interface specification cannot test that
your :meth:`list.append` implementation will actually do this correctly, but it's
your :meth:`!list.append` implementation will actually do this correctly, but it's
trivial to check this property in a test suite.

Writing test suites is very helpful, and you might want to design your code to
Expand Down
13 changes: 8 additions & 5 deletions Doc/faq/library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Is there an equivalent to C's onexit() in Python?
-------------------------------------------------
The :mod:`atexit` module provides a register function that is similar to C's
:c:func:`onexit`.
:c:func:`!onexit`.
Why don't my signal handlers work?
Expand Down Expand Up @@ -397,7 +397,7 @@ These aren't::
D[x] = D[x] + 1
Operations that replace other objects may invoke those other objects'
:meth:`__del__` method when their reference count reaches zero, and that can
:meth:`~object.__del__` method when their reference count reaches zero, and that can
affect things. This is especially true for the mass updates to dictionaries and
lists. When in doubt, use a mutex!
Expand Down Expand Up @@ -730,14 +730,17 @@ The :mod:`select` module is commonly used to help with asynchronous I/O on
sockets.
To prevent the TCP connect from blocking, you can set the socket to non-blocking
mode. Then when you do the :meth:`socket.connect`, you will either connect immediately
mode. Then when you do the :meth:`~socket.socket.connect`,
you will either connect immediately
(unlikely) or get an exception that contains the error number as ``.errno``.
``errno.EINPROGRESS`` indicates that the connection is in progress, but hasn't
finished yet. Different OSes will return different values, so you're going to
have to check what's returned on your system.
You can use the :meth:`socket.connect_ex` method to avoid creating an exception. It will
just return the errno value. To poll, you can call :meth:`socket.connect_ex` again later
You can use the :meth:`~socket.socket.connect_ex` method
to avoid creating an exception.
It will just return the errno value.
To poll, you can call :meth:`~socket.socket.connect_ex` again later
-- ``0`` or ``errno.EISCONN`` indicate that you're connected -- or you can pass this
socket to :meth:`select.select` to check if it's writable.
Expand Down
6 changes: 3 additions & 3 deletions Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ There are two factors that produce this result:
(the list), and both ``x`` and ``y`` refer to it.
2) Lists are :term:`mutable`, which means that you can change their content.

After the call to :meth:`~list.append`, the content of the mutable object has
After the call to :meth:`!append`, the content of the mutable object has
changed from ``[]`` to ``[10]``. Since both the variables refer to the same
object, using either name accesses the modified value ``[10]``.

Expand Down Expand Up @@ -1397,7 +1397,7 @@ To see why this happens, you need to know that (a) if an object implements an
:meth:`~object.__iadd__` magic method, it gets called when the ``+=`` augmented
assignment
is executed, and its return value is what gets used in the assignment statement;
and (b) for lists, :meth:`!__iadd__` is equivalent to calling :meth:`~list.extend` on the list
and (b) for lists, :meth:`!__iadd__` is equivalent to calling :meth:`!extend` on the list
and returning the list. That's why we say that for lists, ``+=`` is a
"shorthand" for :meth:`!list.extend`::

Expand Down Expand Up @@ -1903,7 +1903,7 @@ identity tests. This prevents the code from being confused by objects such as
``float('NaN')`` that are not equal to themselves.

For example, here is the implementation of
:meth:`collections.abc.Sequence.__contains__`::
:meth:`!collections.abc.Sequence.__contains__`::

def __contains__(self, value):
for v in self:
Expand Down
58 changes: 35 additions & 23 deletions Doc/library/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ Handler Objects

Handlers have the following attributes and methods. Note that :class:`Handler`
is never instantiated directly; this class acts as a base for more useful
subclasses. However, the :meth:`__init__` method in subclasses needs to call
subclasses. However, the :meth:`!__init__` method in subclasses needs to call
:meth:`Handler.__init__`.

.. class:: Handler
Expand Down Expand Up @@ -1019,30 +1019,42 @@ information into logging calls. For a usage example, see the section on
'extra'. The return value is a (*msg*, *kwargs*) tuple which has the
(possibly modified) versions of the arguments passed in.

In addition to the above, :class:`LoggerAdapter` supports the following
methods of :class:`Logger`: :meth:`~Logger.debug`, :meth:`~Logger.info`,
:meth:`~Logger.warning`, :meth:`~Logger.error`, :meth:`~Logger.exception`,
:meth:`~Logger.critical`, :meth:`~Logger.log`, :meth:`~Logger.isEnabledFor`,
:meth:`~Logger.getEffectiveLevel`, :meth:`~Logger.setLevel` and
:meth:`~Logger.hasHandlers`. These methods have the same signatures as their
counterparts in :class:`Logger`, so you can use the two types of instances
interchangeably.
.. attribute:: manager

.. versionchanged:: 3.2
The :meth:`~Logger.isEnabledFor`, :meth:`~Logger.getEffectiveLevel`,
:meth:`~Logger.setLevel` and :meth:`~Logger.hasHandlers` methods were added
to :class:`LoggerAdapter`. These methods delegate to the underlying logger.
Delegates to the underlying :attr:`!manager`` on *logger*.

.. attribute:: _log

Delegates to the underlying :meth:`!_log`` method on *logger*.

In addition to the above, :class:`LoggerAdapter` supports the following
methods of :class:`Logger`: :meth:`~Logger.debug`, :meth:`~Logger.info`,
:meth:`~Logger.warning`, :meth:`~Logger.error`, :meth:`~Logger.exception`,
:meth:`~Logger.critical`, :meth:`~Logger.log`, :meth:`~Logger.isEnabledFor`,
:meth:`~Logger.getEffectiveLevel`, :meth:`~Logger.setLevel` and
:meth:`~Logger.hasHandlers`. These methods have the same signatures as their
counterparts in :class:`Logger`, so you can use the two types of instances
interchangeably.

.. versionchanged:: 3.2

.. versionchanged:: 3.6
Attribute :attr:`manager` and method :meth:`_log` were added, which
delegate to the underlying logger and allow adapters to be nested.
The :meth:`~Logger.isEnabledFor`, :meth:`~Logger.getEffectiveLevel`,
:meth:`~Logger.setLevel` and :meth:`~Logger.hasHandlers` methods were added
to :class:`LoggerAdapter`. These methods delegate to the underlying logger.

.. versionchanged:: 3.13
Remove the undocumented ``warn()`` method which was an alias to the
``warning()`` method.
.. versionchanged:: 3.6

Attribute :attr:`!manager` and method :meth:`!_log` were added, which
delegate to the underlying logger and allow adapters to be nested.

.. versionchanged:: 3.13

Remove the undocumented :meth:`!warn`` method which was an alias to the
:meth:`!warning` method.

.. versionchanged:: 3.13

.. versionchanged:: 3.13
The *merge_extra* argument was added.
The *merge_extra* argument was added.


Thread Safety
Expand Down Expand Up @@ -1430,8 +1442,8 @@ functions.
.. function:: setLoggerClass(klass)

Tells the logging system to use the class *klass* when instantiating a logger.
The class should define :meth:`__init__` such that only a name argument is
required, and the :meth:`__init__` should call :meth:`Logger.__init__`. This
The class should define :meth:`!__init__` such that only a name argument is
required, and the :meth:`!__init__` should call :meth:`!Logger.__init__`. This
function is typically called before any loggers are instantiated by applications
which need to use custom logger behavior. After this call, as at any other
time, do not instantiate loggers directly using the subclass: continue to use
Expand Down
4 changes: 0 additions & 4 deletions Doc/tools/.nitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ Doc/c-api/typeobj.rst
Doc/c-api/unicode.rst
Doc/extending/extending.rst
Doc/extending/newtypes.rst
Doc/faq/design.rst
Doc/faq/gui.rst
Doc/faq/library.rst
Doc/faq/programming.rst
Doc/glossary.rst
Doc/howto/descriptor.rst
Doc/howto/enum.rst
Expand Down Expand Up @@ -92,7 +89,6 @@ Doc/library/inspect.rst
Doc/library/locale.rst
Doc/library/logging.config.rst
Doc/library/logging.handlers.rst
Doc/library/logging.rst
Doc/library/lzma.rst
Doc/library/mailbox.rst
Doc/library/mmap.rst
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ def test_bound_builtin_classmethod_o(self):

def test_module_level_callable_unrepresentable_default(self):
self.assertEqual(self._get_summary_line(getattr),
"getattr(object, name, default=<unrepresentable>, /)")
"getattr(...)")

def test_builtin_staticmethod_unrepresentable_default(self):
self.assertEqual(self._get_summary_line(str.maketrans),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Revert converting ``vars``, ``dir``, ``next``, ``getattr``, and ``iter`` to
argument clinic.
Loading

0 comments on commit 70a29b9

Please sign in to comment.