Skip to content

Commit

Permalink
Merge branch '3.11' into diegorusso/3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
diegorusso authored Jan 5, 2024
2 parents 7d36030 + 2a4a724 commit 7acbca0
Show file tree
Hide file tree
Showing 152 changed files with 1,507 additions and 780 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/reusable-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
config_hash:
required: true
type: string
free-threaded:
free-threading:
required: false
type: boolean
default: false
Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
./configure \
--config-cache \
--with-pydebug \
${{ inputs.free-threaded && '--disable-gil' || '' }} \
${{ inputs.free-threading && '--disable-gil' || '' }} \
--prefix=/opt/python-dev \
--with-openssl="$(brew --prefix openssl@3.0)"
- name: Build CPython
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/reusable-windows.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
workflow_call:
inputs:
free-threaded:
free-threading:
required: false
type: boolean
default: false
Expand All @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build CPython
run: .\PCbuild\build.bat -e -d -p Win32 ${{ inputs.free-threaded && '--disable-gil' || '' }}
run: .\PCbuild\build.bat -e -d -p Win32 ${{ inputs.free-threading && '--disable-gil' || '' }}
- name: Display build info
run: .\python.bat -m test.pythoninfo
- name: Tests
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Register MSVC problem matcher
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
- name: Build CPython
run: .\PCbuild\build.bat -e -d -p x64 ${{ inputs.free-threaded && '--disable-gil' || '' }}
run: .\PCbuild\build.bat -e -d -p x64 ${{ inputs.free-threading && '--disable-gil' || '' }}
- name: Display build info
run: .\python.bat -m test.pythoninfo
- name: Tests
Expand All @@ -50,4 +50,4 @@ jobs:
- name: Register MSVC problem matcher
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
- name: Build CPython
run: .\PCbuild\build.bat -e -d -p arm64 ${{ inputs.free-threaded && '--disable-gil' || '' }}
run: .\PCbuild\build.bat -e -d -p arm64 ${{ inputs.free-threading && '--disable-gil' || '' }}
10 changes: 7 additions & 3 deletions Doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ SPHINXERRORHANDLING = -W
PAPEROPT_a4 = -D latex_elements.papersize=a4paper
PAPEROPT_letter = -D latex_elements.papersize=letterpaper

ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees $(PAPEROPT_$(PAPER)) -j $(JOBS) \
$(SPHINXOPTS) $(SPHINXERRORHANDLING) . build/$(BUILDER) $(SOURCES)
ALLSPHINXOPTS = -b $(BUILDER) \
-d build/doctrees \
-j $(JOBS) \
$(PAPEROPT_$(PAPER)) \
$(SPHINXOPTS) $(SPHINXERRORHANDLING) \
. build/$(BUILDER) $(SOURCES)

.PHONY: help
help:
Expand Down Expand Up @@ -156,7 +160,7 @@ htmlview: html

.PHONY: htmllive
htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild
htmllive: SPHINXOPTS = --re-ignore="/venv/"
htmllive: SPHINXOPTS = --re-ignore="/venv/" --open-browser --delay 0
htmllive: html

.PHONY: clean
Expand Down
1 change: 1 addition & 0 deletions Doc/c-api/bytes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ called with a non-bytes parameter.
Return the null-terminated contents of the object *obj*
through the output variables *buffer* and *length*.
Returns ``0`` on success.
If *length* is ``NULL``, the bytes object
may not contain embedded null bytes;
Expand Down
1 change: 1 addition & 0 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
# Attributes/methods/etc. that definitely should be documented better,
# but are deferred for now:
('py:attr', '__annotations__'),
('py:meth', '__missing__'),
('py:attr', '__wrapped__'),
('py:meth', 'index'), # list.index, tuple.index, etc.
]
Expand Down
7 changes: 7 additions & 0 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,13 @@ PyObject_Call:PyObject*:callable_object:0:
PyObject_Call:PyObject*:args:0:
PyObject_Call:PyObject*:kw:0:

PyObject_CallNoArgs:PyObject*::+1:
PyObject_CallNoArgs:PyObject*:callable_object:0:

PyObject_CallOneArg:PyObject*::+1:
PyObject_CallOneArg:PyObject*:callable_object:0:
PyObject_CallOneArg:PyObject*:arg:0:

PyObject_CallFunction:PyObject*::+1:
PyObject_CallFunction:PyObject*:callable_object:0:
PyObject_CallFunction:const char*:format::
Expand Down
4 changes: 2 additions & 2 deletions Doc/howto/isolating-extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ That is, heap types should:

- Have the :c:macro:`Py_TPFLAGS_HAVE_GC` flag.
- Define a traverse function using ``Py_tp_traverse``, which
visits the type (e.g. using :c:expr:`Py_VISIT(Py_TYPE(self))`).
visits the type (e.g. using ``Py_VISIT(Py_TYPE(self))``).

Please refer to the the documentation of
:c:macro:`Py_TPFLAGS_HAVE_GC` and :c:member:`~PyTypeObject.tp_traverse`
Expand Down Expand Up @@ -480,7 +480,7 @@ The largest roadblock is getting *the class a method was defined in*, or
that method's "defining class" for short. The defining class can have a
reference to the module it is part of.

Do not confuse the defining class with :c:expr:`Py_TYPE(self)`. If the method
Do not confuse the defining class with ``Py_TYPE(self)``. If the method
is called on a *subclass* of your type, ``Py_TYPE(self)`` will refer to
that subclass, which may be defined in different module than yours.

Expand Down
33 changes: 18 additions & 15 deletions Doc/library/ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Node classes

This is the base of all AST node classes. The actual node classes are
derived from the :file:`Parser/Python.asdl` file, which is reproduced
:ref:`above <abstract-grammar>`. They are defined in the :mod:`_ast` C
:ref:`above <abstract-grammar>`. They are defined in the :mod:`!_ast` C
module and re-exported in :mod:`ast`.

There is one class defined for each left-hand side symbol in the abstract
Expand Down Expand Up @@ -128,14 +128,14 @@ Node classes

.. deprecated:: 3.8

Old classes :class:`ast.Num`, :class:`ast.Str`, :class:`ast.Bytes`,
:class:`ast.NameConstant` and :class:`ast.Ellipsis` are still available,
Old classes :class:`!ast.Num`, :class:`!ast.Str`, :class:`!ast.Bytes`,
:class:`!ast.NameConstant` and :class:`!ast.Ellipsis` are still available,
but they will be removed in future Python releases. In the meantime,
instantiating them will return an instance of a different class.

.. deprecated:: 3.9

Old classes :class:`ast.Index` and :class:`ast.ExtSlice` are still
Old classes :class:`!ast.Index` and :class:`!ast.ExtSlice` are still
available, but they will be removed in future Python releases.
In the meantime, instantiating them will return an instance of
a different class.
Expand Down Expand Up @@ -1805,8 +1805,7 @@ Function and class definitions
.. class:: arg(arg, annotation, type_comment)

A single argument in a list. ``arg`` is a raw string of the argument
name, ``annotation`` is its annotation, such as a :class:`Str` or
:class:`Name` node.
name; ``annotation`` is its annotation, such as a :class:`Name` node.

.. attribute:: type_comment

Expand Down Expand Up @@ -2140,8 +2139,8 @@ and classes for traversing abstract syntax trees:
.. function:: get_source_segment(source, node, *, padded=False)

Get source code segment of the *source* that generated *node*.
If some location information (:attr:`lineno`, :attr:`end_lineno`,
:attr:`col_offset`, or :attr:`end_col_offset`) is missing, return ``None``.
If some location information (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.end_lineno`,
:attr:`~ast.AST.col_offset`, or :attr:`~ast.AST.end_col_offset`) is missing, return ``None``.

If *padded* is ``True``, the first line of a multi-line statement will
be padded with spaces to match its original position.
Expand All @@ -2152,7 +2151,7 @@ and classes for traversing abstract syntax trees:
.. function:: fix_missing_locations(node)

When you compile a node tree with :func:`compile`, the compiler expects
:attr:`lineno` and :attr:`col_offset` attributes for every node that supports
:attr:`~ast.AST.lineno` and :attr:`~ast.AST.col_offset` attributes for every node that supports
them. This is rather tedious to fill in for generated nodes, so this helper
adds these attributes recursively where not already set, by setting them to
the values of the parent node. It works recursively starting at *node*.
Expand All @@ -2167,8 +2166,8 @@ and classes for traversing abstract syntax trees:

.. function:: copy_location(new_node, old_node)

Copy source location (:attr:`lineno`, :attr:`col_offset`, :attr:`end_lineno`,
and :attr:`end_col_offset`) from *old_node* to *new_node* if possible,
Copy source location (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.col_offset`, :attr:`~ast.AST.end_lineno`,
and :attr:`~ast.AST.end_col_offset`) from *old_node* to *new_node* if possible,
and return *new_node*.


Expand Down Expand Up @@ -2214,14 +2213,18 @@ and classes for traversing abstract syntax trees:
visited unless the visitor calls :meth:`generic_visit` or visits them
itself.

.. method:: visit_Constant(node)

Handles all constant nodes.

Don't use the :class:`NodeVisitor` if you want to apply changes to nodes
during traversal. For this a special visitor exists
(:class:`NodeTransformer`) that allows modifications.

.. deprecated:: 3.8

Methods :meth:`visit_Num`, :meth:`visit_Str`, :meth:`visit_Bytes`,
:meth:`visit_NameConstant` and :meth:`visit_Ellipsis` are deprecated
Methods :meth:`!visit_Num`, :meth:`!visit_Str`, :meth:`!visit_Bytes`,
:meth:`!visit_NameConstant` and :meth:`!visit_Ellipsis` are deprecated
now and will not be called in future Python versions. Add the
:meth:`visit_Constant` method to handle all constant nodes.

Expand Down Expand Up @@ -2250,7 +2253,7 @@ and classes for traversing abstract syntax trees:
)

Keep in mind that if the node you're operating on has child nodes you must
either transform the child nodes yourself or call the :meth:`generic_visit`
either transform the child nodes yourself or call the :meth:`~ast.NodeVisitor.generic_visit`
method for the node first.

For nodes that were part of a collection of statements (that applies to all
Expand All @@ -2259,7 +2262,7 @@ and classes for traversing abstract syntax trees:

If :class:`NodeTransformer` introduces new nodes (that weren't part of
original tree) without giving them location information (such as
:attr:`lineno`), :func:`fix_missing_locations` should be called with
:attr:`~ast.AST.lineno`), :func:`fix_missing_locations` should be called with
the new sub-tree to recalculate the location information::

tree = ast.parse('foo', mode='eval')
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/bisect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The following functions are provided:
Insert *x* in *a* in sorted order.

This function first runs :py:func:`~bisect.bisect_left` to locate an insertion point.
Next, it runs the :meth:`insert` method on *a* to insert *x* at the
Next, it runs the :meth:`!insert` method on *a* to insert *x* at the
appropriate position to maintain sort order.

To support inserting records in a table, the *key* function (if any) is
Expand All @@ -93,7 +93,7 @@ The following functions are provided:
entries of *x*.

This function first runs :py:func:`~bisect.bisect_right` to locate an insertion point.
Next, it runs the :meth:`insert` method on *a* to insert *x* at the
Next, it runs the :meth:`!insert` method on *a* to insert *x* at the
appropriate position to maintain sort order.

To support inserting records in a table, the *key* function (if any) is
Expand Down
13 changes: 10 additions & 3 deletions Doc/library/calendar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
output (defaulting to the system default encoding).


.. method:: formatmonthname(theyear, themonth, withyear=True)

Return a month name as an HTML table row. If *withyear* is true the year
will be included in the row, otherwise just the month name will be
used.


:class:`!HTMLCalendar` has the following attributes you can override to
customize the CSS classes used by the calendar:

Expand Down Expand Up @@ -289,7 +296,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is

.. note::

The constructor, :meth:`formatweekday` and :meth:`formatmonthname` methods
The constructor, :meth:`!formatweekday` and :meth:`!formatmonthname` methods
of these two classes temporarily change the ``LC_TIME`` locale to the given
*locale*. Because the current locale is a process-wide setting, they are
not thread-safe.
Expand Down Expand Up @@ -358,7 +365,7 @@ For simple text calendars this module provides the following functions.

.. function:: month(theyear, themonth, w=0, l=0)

Returns a month's calendar in a multi-line string using the :meth:`formatmonth`
Returns a month's calendar in a multi-line string using the :meth:`~TextCalendar.formatmonth`
of the :class:`TextCalendar` class.


Expand All @@ -370,7 +377,7 @@ For simple text calendars this module provides the following functions.
.. function:: calendar(year, w=2, l=1, c=6, m=3)

Returns a 3-column calendar for an entire year as a multi-line string using
the :meth:`formatyear` of the :class:`TextCalendar` class.
the :meth:`~TextCalendar.formatyear` of the :class:`TextCalendar` class.


.. function:: timegm(tuple)
Expand Down
25 changes: 14 additions & 11 deletions Doc/library/cmd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,30 @@ A :class:`Cmd` instance has the following methods:
single: ! (exclamation); in a command interpreter

An interpreter instance will recognize a command name ``foo`` if and only if it
has a method :meth:`do_foo`. As a special case, a line beginning with the
has a method :meth:`!do_foo`. As a special case, a line beginning with the
character ``'?'`` is dispatched to the method :meth:`do_help`. As another
special case, a line beginning with the character ``'!'`` is dispatched to the
method :meth:`do_shell` (if such a method is defined).
method :meth:`!do_shell` (if such a method is defined).

This method will return when the :meth:`postcmd` method returns a true value.
The *stop* argument to :meth:`postcmd` is the return value from the command's
corresponding :meth:`!do_\*` method.

If completion is enabled, completing commands will be done automatically, and
completing of commands args is done by calling :meth:`complete_foo` with
completing of commands args is done by calling :meth:`!complete_foo` with
arguments *text*, *line*, *begidx*, and *endidx*. *text* is the string prefix
we are attempting to match: all returned matches must begin with it. *line* is
the current input line with leading whitespace removed, *begidx* and *endidx*
are the beginning and ending indexes of the prefix text, which could be used to
provide different completion depending upon which position the argument is in.

All subclasses of :class:`Cmd` inherit a predefined :meth:`do_help`. This

.. method:: Cmd.do_help(arg)

All subclasses of :class:`Cmd` inherit a predefined :meth:`!do_help`. This
method, called with an argument ``'bar'``, invokes the corresponding method
:meth:`help_bar`, and if that is not present, prints the docstring of
:meth:`do_bar`, if available. With no argument, :meth:`do_help` lists all
:meth:`!help_bar`, and if that is not present, prints the docstring of
:meth:`!do_bar`, if available. With no argument, :meth:`!do_help` lists all
available help topics (that is, all commands with corresponding
:meth:`!help_\*` methods or commands that have docstrings), and also lists any
undocumented commands.
Expand Down Expand Up @@ -219,8 +222,8 @@ Instances of :class:`Cmd` subclasses have some public instance variables:
.. attribute:: Cmd.use_rawinput

A flag, defaulting to true. If true, :meth:`cmdloop` uses :func:`input` to
display a prompt and read the next command; if false, :meth:`sys.stdout.write`
and :meth:`sys.stdin.readline` are used. (This means that by importing
display a prompt and read the next command; if false, :data:`sys.stdout.write() <sys.stdout>`
and :data:`sys.stdin.readline() <sys.stdin>` are used. (This means that by importing
:mod:`readline`, on systems that support it, the interpreter will automatically
support :program:`Emacs`\ -like line editing and command-history keystrokes.)

Expand All @@ -239,14 +242,14 @@ This section presents a simple example of how to build a shell around a few of
the commands in the :mod:`turtle` module.

Basic turtle commands such as :meth:`~turtle.forward` are added to a
:class:`Cmd` subclass with method named :meth:`do_forward`. The argument is
:class:`Cmd` subclass with method named :meth:`!do_forward`. The argument is
converted to a number and dispatched to the turtle module. The docstring is
used in the help utility provided by the shell.

The example also includes a basic record and playback facility implemented with
the :meth:`~Cmd.precmd` method which is responsible for converting the input to
lowercase and writing the commands to a file. The :meth:`do_playback` method
reads the file and adds the recorded commands to the :attr:`cmdqueue` for
lowercase and writing the commands to a file. The :meth:`!do_playback` method
reads the file and adds the recorded commands to the :attr:`~Cmd.cmdqueue` for
immediate playback::

import cmd, sys
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/collections.abc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ the required methods (unless those methods have been set to

class E:
def __iter__(self): ...
def __next__(next): ...
def __next__(self): ...

.. doctest::

Expand Down
Loading

0 comments on commit 7acbca0

Please sign in to comment.