Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into split
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel committed Sep 2, 2024
2 parents b4d077b + 57c471a commit 70e1b5b
Show file tree
Hide file tree
Showing 109 changed files with 1,159 additions and 509 deletions.
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ Doc/c-api/stable.rst @encukou

**/*ensurepip* @pfmoore @pradyunsg

**/*idlelib* @terryjreedy
/Doc/library/idle.rst @terryjreedy
**/*idlelib* @terryjreedy
**/*turtledemo* @terryjreedy

**/*annotationlib* @JelleZijlstra
**/*typing* @JelleZijlstra @AlexWaygood
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/reusable-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
FORCE_COLOR: 1

jobs:
build_doc:
name: 'Docs'
Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ Macros for the convenience of modules implementing the DB API:
.. c:function:: PyObject* PyDateTime_FromTimestamp(PyObject *args)
Create and return a new :class:`datetime.datetime` object given an argument
tuple suitable for passing to :meth:`datetime.datetime.fromtimestamp()`.
tuple suitable for passing to :meth:`datetime.datetime.fromtimestamp`.
.. c:function:: PyObject* PyDate_FromTimestamp(PyObject *args)
Create and return a new :class:`datetime.date` object given an argument
tuple suitable for passing to :meth:`datetime.date.fromtimestamp()`.
tuple suitable for passing to :meth:`datetime.date.fromtimestamp`.
1 change: 1 addition & 0 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@
# Allow translation of index directives
gettext_additional_targets = [
'index',
'literal-block',
]

# Options for HTML output
Expand Down
2 changes: 1 addition & 1 deletion Doc/deprecations/pending-removal-in-future.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ although there is currently no date scheduled for their removal.
* Implicit ``None`` on return values.

* :mod:`logging`: the ``warn()`` method has been deprecated
since Python 3.3, use :meth:`~logging.warning()` instead.
since Python 3.3, use :meth:`~logging.warning` instead.

* :mod:`mailbox`: Use of StringIO input and text mode is deprecated, use
BytesIO and binary mode instead.
Expand Down
2 changes: 1 addition & 1 deletion Doc/extending/newtypes_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ Further, the attributes can be deleted, setting the C pointers to ``NULL``. Eve
though we can make sure the members are initialized to non-``NULL`` values, the
members can be set to ``NULL`` if the attributes are deleted.

We define a single method, :meth:`!Custom.name()`, that outputs the objects name as the
We define a single method, :meth:`!Custom.name`, that outputs the objects name as the
concatenation of the first and last names. ::

static PyObject *
Expand Down
2 changes: 1 addition & 1 deletion Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ Not as such.
For simple input parsing, the easiest approach is usually to split the line into
whitespace-delimited words using the :meth:`~str.split` method of string objects
and then convert decimal strings to numeric values using :func:`int` or
:func:`float`. :meth:`!split()` supports an optional "sep" parameter which is useful
:func:`float`. :meth:`!split` supports an optional "sep" parameter which is useful
if the line uses something other than whitespace as a separator.

For more complicated input parsing, regular expressions are more powerful
Expand Down
55 changes: 16 additions & 39 deletions Doc/howto/descriptor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ The full C implementation can be found in :c:func:`!super_getattro` in
Summary of invocation logic
---------------------------

The mechanism for descriptors is embedded in the :meth:`__getattribute__()`
The mechanism for descriptors is embedded in the :meth:`__getattribute__`
methods for :class:`object`, :class:`type`, and :func:`super`.

The important points to remember are:
Expand Down Expand Up @@ -990,7 +990,7 @@ The documentation shows a typical use to define a managed attribute ``x``:
AttributeError: 'C' object has no attribute '_C__x'

To see how :func:`property` is implemented in terms of the descriptor protocol,
here is a pure Python equivalent:
here is a pure Python equivalent that implements most of the core functionality:

.. testcode::

Expand All @@ -1004,59 +1004,36 @@ here is a pure Python equivalent:
if doc is None and fget is not None:
doc = fget.__doc__
self.__doc__ = doc
self._name = None
self.__name__ = ''

def __set_name__(self, owner, name):
self._name = name

@property
def __name__(self):
return self._name if self._name is not None else self.fget.__name__

@__name__.setter
def __name__(self, value):
self._name = value
self.__name__ = name

def __get__(self, obj, objtype=None):
if obj is None:
return self
if self.fget is None:
raise AttributeError(
f'property {self.__name__!r} of {type(obj).__name__!r} '
'object has no getter'
)
raise AttributeError
return self.fget(obj)

def __set__(self, obj, value):
if self.fset is None:
raise AttributeError(
f'property {self.__name__!r} of {type(obj).__name__!r} '
'object has no setter'
)
raise AttributeError
self.fset(obj, value)

def __delete__(self, obj):
if self.fdel is None:
raise AttributeError(
f'property {self.__name__!r} of {type(obj).__name__!r} '
'object has no deleter'
)
raise AttributeError
self.fdel(obj)

def getter(self, fget):
prop = type(self)(fget, self.fset, self.fdel, self.__doc__)
prop._name = self._name
return prop
return type(self)(fget, self.fset, self.fdel, self.__doc__)

def setter(self, fset):
prop = type(self)(self.fget, fset, self.fdel, self.__doc__)
prop._name = self._name
return prop
return type(self)(self.fget, fset, self.fdel, self.__doc__)

def deleter(self, fdel):
prop = type(self)(self.fget, self.fset, fdel, self.__doc__)
prop._name = self._name
return prop
return type(self)(self.fget, self.fset, fdel, self.__doc__)

.. testcode::
:hide:
Expand Down Expand Up @@ -1119,23 +1096,23 @@ here is a pure Python equivalent:
>>> try:
... cc.no_getter
... except AttributeError as e:
... e.args[0]
... type(e).__name__
...
"property 'no_getter' of 'CC' object has no getter"
'AttributeError'

>>> try:
... cc.no_setter = 33
... except AttributeError as e:
... e.args[0]
... type(e).__name__
...
"property 'no_setter' of 'CC' object has no setter"
'AttributeError'

>>> try:
... del cc.no_deleter
... except AttributeError as e:
... e.args[0]
... type(e).__name__
...
"property 'no_deleter' of 'CC' object has no deleter"
'AttributeError'

>>> CC.no_doc.__doc__ is None
True
Expand Down
8 changes: 4 additions & 4 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Running and stopping the loop

Run the event loop until :meth:`stop` is called.

If :meth:`stop` is called before :meth:`run_forever()` is called,
If :meth:`stop` is called before :meth:`run_forever` is called,
the loop will poll the I/O selector once with a timeout of zero,
run all callbacks scheduled in response to I/O events (and
those that were already scheduled), and then exit.
Expand Down Expand Up @@ -165,7 +165,7 @@ Running and stopping the loop
.. coroutinemethod:: loop.shutdown_asyncgens()

Schedule all currently open :term:`asynchronous generator` objects to
close with an :meth:`~agen.aclose()` call. After calling this method,
close with an :meth:`~agen.aclose` call. After calling this method,
the event loop will issue a warning if a new asynchronous generator
is iterated. This should be used to reliably finalize all scheduled
asynchronous generators.
Expand Down Expand Up @@ -1402,7 +1402,7 @@ Allows customizing how exceptions are handled in the event loop.

This method should not be overloaded in subclassed
event loops. For custom exception handling, use
the :meth:`set_exception_handler()` method.
the :meth:`set_exception_handler` method.

Enabling debug mode
^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -1485,7 +1485,7 @@ async/await code consider using the high-level
* *stdin* can be any of these:

* a file-like object
* an existing file descriptor (a positive integer), for example those created with :meth:`os.pipe()`
* an existing file descriptor (a positive integer), for example those created with :meth:`os.pipe`
* the :const:`subprocess.PIPE` constant (default) which will create a new
pipe and connect it,
* the value ``None`` which will make the subprocess inherit the file
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/asyncio-llapi-index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ See also the main documentation section about the
* - :meth:`loop.close`
- Close the event loop.

* - :meth:`loop.is_running()`
* - :meth:`loop.is_running`
- Return ``True`` if the event loop is running.

* - :meth:`loop.is_closed()`
* - :meth:`loop.is_closed`
- Return ``True`` if the event loop is closed.

* - ``await`` :meth:`loop.shutdown_asyncgens`
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-queue.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Queue
Return ``True`` if there are :attr:`maxsize` items in the queue.

If the queue was initialized with ``maxsize=0`` (the default),
then :meth:`full()` never returns ``True``.
then :meth:`full` never returns ``True``.

.. coroutinemethod:: get()

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/configparser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ ConfigParser Objects
When *converters* is given, it should be a dictionary where each key
represents the name of a type converter and each value is a callable
implementing the conversion from string to the desired datatype. Every
converter gets its own corresponding :meth:`!get*()` method on the parser
converter gets its own corresponding :meth:`!get*` method on the parser
object and section proxies.

It is possible to read several configurations into a single
Expand Down Expand Up @@ -1026,7 +1026,7 @@ ConfigParser Objects
The *converters* argument was added.

.. versionchanged:: 3.7
The *defaults* argument is read with :meth:`read_dict()`,
The *defaults* argument is read with :meth:`read_dict`,
providing consistent behavior across the parser: non-string
keys and values are implicitly converted to strings.

Expand Down
24 changes: 18 additions & 6 deletions Doc/library/dataclasses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Module contents
- *unsafe_hash*: If ``False`` (the default), a :meth:`~object.__hash__` method
is generated according to how *eq* and *frozen* are set.

:meth:`!__hash__` is used by built-in :meth:`hash()`, and when objects are
:meth:`!__hash__` is used by built-in :meth:`hash`, and when objects are
added to hashed collections such as dictionaries and sets. Having a
:meth:`!__hash__` implies that instances of the class are immutable.
Mutability is a complicated property that depends on the programmer's
Expand Down Expand Up @@ -185,10 +185,21 @@ Module contents
- *slots*: If true (the default is ``False``), :attr:`~object.__slots__` attribute
will be generated and new class will be returned instead of the original one.
If :attr:`!__slots__` is already defined in the class, then :exc:`TypeError`
is raised. Calling no-arg :func:`super` in dataclasses using ``slots=True`` will result in
the following exception being raised:
``TypeError: super(type, obj): obj must be an instance or subtype of type``.
The two-arg :func:`super` is a valid workaround. See :gh:`90562` for full details.
is raised.

.. warning::
Calling no-arg :func:`super` in dataclasses using ``slots=True``
will result in the following exception being raised:
``TypeError: super(type, obj): obj must be an instance or subtype of type``.
The two-arg :func:`super` is a valid workaround.
See :gh:`90562` for full details.

.. warning::
Passing parameters to a base class :meth:`~object.__init_subclass__`
when using ``slots=True`` will result in a :exc:`TypeError`.
Either use ``__init_subclass__`` with no parameters
or use default values as a workaround.
See :gh:`91126` for full details.

.. versionadded:: 3.10

Expand All @@ -204,7 +215,8 @@ Module contents

- *weakref_slot*: If true (the default is ``False``), add a slot
named "__weakref__", which is required to make an instance
weakref-able. It is an error to specify ``weakref_slot=True``
:func:`weakref-able <weakref.ref>`.
It is an error to specify ``weakref_slot=True``
without also specifying ``slots=True``.

.. versionadded:: 3.11
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ Other constructors, all class methods:
.. versionadded:: 3.7
.. versionchanged:: 3.11
Previously, this method only supported formats that could be emitted by
:meth:`date.isoformat()` or :meth:`datetime.isoformat()`.
:meth:`date.isoformat` or :meth:`datetime.isoformat`.


.. classmethod:: datetime.fromisocalendar(year, week, day)
Expand Down Expand Up @@ -1861,7 +1861,7 @@ Other constructor:
.. versionadded:: 3.7
.. versionchanged:: 3.11
Previously, this method only supported formats that could be emitted by
:meth:`time.isoformat()`.
:meth:`time.isoformat`.


Instance methods:
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1118,8 +1118,8 @@ iterations of the loop.
if count == 0:
value = ()
else:
STACK = STACK[:-count]
value = tuple(STACK[-count:])
STACK = STACK[:-count]

STACK.append(value)

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/email.compat32-message.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Here are the methods of the :class:`Message` class:

.. method:: __str__()

Equivalent to :meth:`.as_string()`. Allows ``str(msg)`` to produce a
Equivalent to :meth:`.as_string`. Allows ``str(msg)`` to produce a
string containing the formatted message.


Expand Down Expand Up @@ -143,7 +143,7 @@ Here are the methods of the :class:`Message` class:

.. method:: __bytes__()

Equivalent to :meth:`.as_bytes()`. Allows ``bytes(msg)`` to produce a
Equivalent to :meth:`.as_bytes`. Allows ``bytes(msg)`` to produce a
bytes object containing the formatted message.

.. versionadded:: 3.4
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/email.message.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ message objects.

.. method:: __bytes__()

Equivalent to :meth:`.as_bytes()`. Allows ``bytes(msg)`` to produce a
Equivalent to :meth:`.as_bytes`. Allows ``bytes(msg)`` to produce a
bytes object containing the serialized message.


Expand Down
2 changes: 1 addition & 1 deletion Doc/library/http.server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ provides three different variants:

Adds a blank line
(indicating the end of the HTTP headers in the response)
to the headers buffer and calls :meth:`flush_headers()`.
to the headers buffer and calls :meth:`flush_headers`.

.. versionchanged:: 3.2
The buffered headers are written to the output stream.
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ the backing store is natively made of bytes (such as in the case of a file),
encoding and decoding of data is made transparently as well as optional
translation of platform-specific newline characters.

The easiest way to create a text stream is with :meth:`open()`, optionally
The easiest way to create a text stream is with :meth:`open`, optionally
specifying an encoding::

f = open("myfile.txt", "r", encoding="utf-8")
Expand All @@ -77,7 +77,7 @@ objects. No encoding, decoding, or newline translation is performed. This
category of streams can be used for all kinds of non-text data, and also when
manual control over the handling of text data is desired.

The easiest way to create a binary stream is with :meth:`open()` with ``'b'`` in
The easiest way to create a binary stream is with :meth:`open` with ``'b'`` in
the mode string::

f = open("myfile.jpg", "rb")
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/logging.config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ in :mod:`logging` itself) and defining handlers which are declared either in
dictConfigClass(config).configure()

For example, a subclass of :class:`DictConfigurator` could call
``DictConfigurator.__init__()`` in its own :meth:`__init__()`, then
``DictConfigurator.__init__()`` in its own :meth:`__init__`, then
set up custom prefixes which would be usable in the subsequent
:meth:`configure` call. :attr:`dictConfigClass` would be bound to
this new subclass, and then :func:`dictConfig` could be called exactly as
Expand Down
Loading

0 comments on commit 70e1b5b

Please sign in to comment.