Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into tier2_superinstruct…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
Fidget-Spinner committed Mar 4, 2024
2 parents cd0ad10 + ffed8d9 commit 4861d7d
Show file tree
Hide file tree
Showing 85 changed files with 2,179 additions and 723 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/jit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
target:
- i686-pc-windows-msvc/msvc
- x86_64-pc-windows-msvc/msvc
- aarch64-pc-windows-msvc/msvc
- x86_64-apple-darwin/clang
- aarch64-apple-darwin/clang
- x86_64-unknown-linux-gnu/gcc
Expand All @@ -49,6 +50,10 @@ jobs:
architecture: x64
runner: windows-latest
compiler: msvc
- target: aarch64-pc-windows-msvc/msvc
architecture: ARM64
runner: windows-latest
compiler: msvc
- target: x86_64-apple-darwin/clang
architecture: x86_64
runner: macos-13
Expand Down Expand Up @@ -85,14 +90,21 @@ jobs:
with:
python-version: '3.11'

- name: Windows
if: runner.os == 'Windows'
- name: Native Windows
if: runner.os == 'Windows' && matrix.architecture != 'ARM64'
run: |
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '--pgo' }} -p ${{ matrix.architecture }}
./PCbuild/rt.bat ${{ matrix.debug && '-d' }} -p ${{ matrix.architecture }} -q --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
- name: macOS
# No PGO or tests (yet):
- name: Emulated Windows
if: runner.os == 'Windows' && matrix.architecture == 'ARM64'
run: |
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
- name: Native macOS
if: runner.os == 'macOS'
run: |
brew install llvm@${{ matrix.llvm }}
Expand Down
8 changes: 5 additions & 3 deletions Doc/faq/general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ Python versions are numbered "A.B.C" or "A.B":
changes.
* *C* is the micro version number -- it is incremented for each bugfix release.

See :pep:`6` for more information about bugfix releases.

Not all releases are bugfix releases. In the run-up to a new feature release, a
series of development releases are made, denoted as alpha, beta, or release
candidate. Alphas are early releases in which interfaces aren't yet finalized;
Expand All @@ -157,7 +155,11 @@ unreleased versions, built directly from the CPython development repository. In
practice, after a final minor release is made, the version is incremented to the
next minor version, which becomes the "a0" version, e.g. "2.4a0".

See also the documentation for :data:`sys.version`, :data:`sys.hexversion`, and
See the `Developer's Guide
<https://devguide.python.org/developer-workflow/development-cycle/>`__
for more information about the development cycle, and
:pep:`387` to learn more about Python's backward compatibility policy. See also
the documentation for :data:`sys.version`, :data:`sys.hexversion`, and
:data:`sys.version_info`.


Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-stream.rst
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ StreamWriter
be resumed. When there is nothing to wait for, the :meth:`drain`
returns immediately.

.. coroutinemethod:: start_tls(sslcontext, \*, server_hostname=None, \
.. coroutinemethod:: start_tls(sslcontext, *, server_hostname=None, \
ssl_handshake_timeout=None, ssl_shutdown_timeout=None)

Upgrade an existing stream-based connection to TLS.
Expand Down
10 changes: 8 additions & 2 deletions Doc/library/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,9 @@ Supported operations:

Naive and aware :class:`!datetime` objects are never equal.

If both comparands are aware, and have the same :attr:`!tzinfo` attribute,
the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and
the base datetimes are compared.
If both comparands are aware and have different :attr:`~.datetime.tzinfo`
attributes, the comparison acts as comparands were first converted to UTC
datetimes except that the implementation never overflows.
Expand All @@ -1222,6 +1225,9 @@ Supported operations:
Order comparison between naive and aware :class:`.datetime` objects
raises :exc:`TypeError`.

If both comparands are aware, and have the same :attr:`!tzinfo` attribute,
the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and
the base datetimes are compared.
If both comparands are aware and have different :attr:`~.datetime.tzinfo`
attributes, the comparison acts as comparands were first converted to UTC
datetimes except that the implementation never overflows.
Expand Down Expand Up @@ -1778,8 +1784,8 @@ Naive and aware :class:`!time` objects are never equal.
Order comparison between naive and aware :class:`!time` objects raises
:exc:`TypeError`.

If both comparands are aware, and have
the same :attr:`~.time.tzinfo` attribute, the common :attr:`!tzinfo` attribute is
If both comparands are aware, and have the same :attr:`~.time.tzinfo`
attribute, the :attr:`!tzinfo` and :attr:`!fold` attributes are
ignored and the base times are compared. If both comparands are aware and
have different :attr:`!tzinfo` attributes, the comparands are first adjusted by
subtracting their UTC offsets (obtained from ``self.utcoffset()``).
Expand Down
8 changes: 4 additions & 4 deletions Doc/library/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Data Types
final *enum*, as well as creating the enum members, properly handling
duplicates, providing iteration over the enum class, etc.

.. method:: EnumType.__call__(cls, value, names=None, \*, module=None, qualname=None, type=None, start=1, boundary=None)
.. method:: EnumType.__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

This method is called in two different ways:

Expand Down Expand Up @@ -350,7 +350,7 @@ Data Types
>>> PowersOfThree.SECOND.value
9

.. method:: Enum.__init__(self, \*args, \**kwds)
.. method:: Enum.__init__(self, *args, **kwds)

By default, does nothing. If multiple values are given in the member
assignment, those values become separate arguments to ``__init__``; e.g.
Expand All @@ -361,7 +361,7 @@ Data Types

``Weekday.__init__()`` would be called as ``Weekday.__init__(self, 1, 'Mon')``

.. method:: Enum.__init_subclass__(cls, \**kwds)
.. method:: Enum.__init_subclass__(cls, **kwds)

A *classmethod* that is used to further configure subsequent subclasses.
By default, does nothing.
Expand All @@ -388,7 +388,7 @@ Data Types
>>> Build('deBUG')
<Build.DEBUG: 'debug'>

.. method:: Enum.__new__(cls, \*args, \**kwds)
.. method:: Enum.__new__(cls, *args, **kwds)

By default, doesn't exist. If specified, either in the enum class
definition or in a mixin class (such as ``int``), all values given
Expand Down
9 changes: 7 additions & 2 deletions Doc/library/filecmp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,20 @@ The :mod:`filecmp` module defines the following functions:
The :class:`dircmp` class
-------------------------

.. class:: dircmp(a, b, ignore=None, hide=None)
.. class:: dircmp(a, b, ignore=None, hide=None, shallow=True)

Construct a new directory comparison object, to compare the directories *a*
and *b*. *ignore* is a list of names to ignore, and defaults to
:const:`filecmp.DEFAULT_IGNORES`. *hide* is a list of names to hide, and
defaults to ``[os.curdir, os.pardir]``.

The :class:`dircmp` class compares files by doing *shallow* comparisons
as described for :func:`filecmp.cmp`.
as described for :func:`filecmp.cmp` by default using the *shallow*
parameter.

.. versionchanged:: 3.13

Added the *shallow* parameter.

The :class:`dircmp` class provides the following methods:

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/hashlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ More condensed:
Constructors
------------

.. function:: new(name[, data], \*, usedforsecurity=True)
.. function:: new(name[, data], *, usedforsecurity=True)

Is a generic constructor that takes the string *name* of the desired
algorithm as its first parameter. It also exists to allow access to the
Expand Down
6 changes: 6 additions & 0 deletions Doc/library/http.server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,12 @@ the ``--cgi`` option::
:mod:`http.server` command line ``--cgi`` support is being removed
because :class:`CGIHTTPRequestHandler` is being removed.

.. warning::

:class:`CGIHTTPRequestHandler` and the ``--cgi`` command line option
are not intended for use by untrusted clients and may be vulnerable
to exploitation. Always use within a secure environment.

.. _http.server-security:

Security Considerations
Expand Down
39 changes: 16 additions & 23 deletions Doc/library/itertools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ Iterator Arguments Results
:func:`chain` p, q, ... p0, p1, ... plast, q0, q1, ... ``chain('ABC', 'DEF') --> A B C D E F``
:func:`chain.from_iterable` iterable p0, p1, ... plast, q0, q1, ... ``chain.from_iterable(['ABC', 'DEF']) --> A B C D E F``
:func:`compress` data, selectors (d[0] if s[0]), (d[1] if s[1]), ... ``compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F``
:func:`dropwhile` pred, seq seq[n], seq[n+1], starting when pred fails ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1``
:func:`filterfalse` pred, seq elements of seq where pred(elem) is false ``filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
:func:`dropwhile` predicate, seq seq[n], seq[n+1], starting when predicate fails ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1``
:func:`filterfalse` predicate, seq elements of seq where predicate(elem) fails ``filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
:func:`groupby` iterable[, key] sub-iterators grouped by value of key(v)
:func:`islice` seq, [start,] stop [, step] elements from seq[start:stop:step] ``islice('ABCDEFG', 2, None) --> C D E F G``
:func:`pairwise` iterable (p[0], p[1]), (p[1], p[2]) ``pairwise('ABCDEFG') --> AB BC CD DE EF FG``
:func:`starmap` func, seq func(\*seq[0]), func(\*seq[1]), ... ``starmap(pow, [(2,5), (3,2), (10,3)]) --> 32 9 1000``
:func:`takewhile` pred, seq seq[0], seq[1], until pred fails ``takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4``
:func:`takewhile` predicate, seq seq[0], seq[1], until predicate fails ``takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4``
:func:`tee` it, n it1, it2, ... itn splits one iterator into n
:func:`zip_longest` p, q, ... (p[0], q[0]), (p[1], q[1]), ... ``zip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D-``
============================ ============================ ================================================= =============================================================
Expand Down Expand Up @@ -90,7 +90,7 @@ Examples Results

.. _itertools-functions:

Itertool functions
Itertool Functions
------------------

The following module functions all construct and return iterators. Some provide
Expand Down Expand Up @@ -859,27 +859,20 @@ which incur interpreter overhead.
"Returns the nth item or a default value."
return next(islice(iterable, n, None), default)

def quantify(iterable, pred=bool):
def quantify(iterable, predicate=bool):
"Given a predicate that returns True or False, count the True results."
return sum(map(pred, iterable))
return sum(map(predicate, iterable))

def first_true(iterable, default=False, predicate=None):
"Returns the first true value or the *default* if there is no true value."
# first_true([a,b,c], x) --> a or b or c or x
# first_true([a,b], x, f) --> a if f(a) else b if f(b) else x
return next(filter(predicate, iterable), default)

def all_equal(iterable, key=None):
"Returns True if all the elements are equal to each other."
return len(take(2, groupby(iterable, key))) <= 1

def first_true(iterable, default=False, pred=None):
"""Returns the first true value in the iterable.

If no true value is found, returns *default*

If *pred* is not None, returns the first item
for which pred(item) is true.

"""
# first_true([a,b,c], x) --> a or b or c or x
# first_true([a,b], x, f) --> a if f(a) else b if f(b) else x
return next(filter(pred, iterable), default)

def unique_everseen(iterable, key=None):
"List unique elements, preserving order. Remember all elements ever seen."
# unique_everseen('AAAABBBCCDAABBB') --> A B C D
Expand Down Expand Up @@ -964,14 +957,14 @@ which incur interpreter overhead.
num_active -= 1
nexts = cycle(islice(nexts, num_active))
def partition(pred, iterable):
def partition(predicate, iterable):
"""Partition entries into false entries and true entries.

If *pred* is slow, consider wrapping it with functools.lru_cache().
If *predicate* is slow, consider wrapping it with functools.lru_cache().
"""
# partition(is_odd, range(10)) --> 0 2 4 6 8 and 1 3 5 7 9
t1, t2 = tee(iterable)
return filterfalse(pred, t1), filter(pred, t2)
return filterfalse(predicate, t1), filter(predicate, t2)

def subslices(seq):
"Return all contiguous non-empty subslices of a sequence."
Expand Down Expand Up @@ -1214,7 +1207,7 @@ The following recipes have a more mathematical flavor:
>>> quantify([True, False, False, True, True])
3

>>> quantify(range(12), pred=lambda x: x%2==1)
>>> quantify(range(12), predicate=lambda x: x%2==1)
6

>>> a = [[1, 2, 3], [4, 5, 6]]
Expand Down
11 changes: 8 additions & 3 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1812,12 +1812,15 @@ Basic customization
rather, :meth:`__lt__` and :meth:`__gt__` are each other's reflection,
:meth:`__le__` and :meth:`__ge__` are each other's reflection, and
:meth:`__eq__` and :meth:`__ne__` are their own reflection.
If the operands are of different types, and right operand's type is
If the operands are of different types, and the right operand's type is
a direct or indirect subclass of the left operand's type,
the reflected method of the right operand has priority, otherwise
the left operand's method has priority. Virtual subclassing is
not considered.

When no appropriate method returns any value other than :data:`NotImplemented`, the
``==`` and ``!=`` operators will fall back to ``is`` and ``is not``, respectively.

.. method:: object.__hash__(self)

.. index::
Expand Down Expand Up @@ -3044,10 +3047,12 @@ left undefined.
(``+=``, ``-=``, ``*=``, ``@=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``,
``>>=``, ``&=``, ``^=``, ``|=``). These methods should attempt to do the
operation in-place (modifying *self*) and return the result (which could be,
but does not have to be, *self*). If a specific method is not defined, the
but does not have to be, *self*). If a specific method is not defined, or if
that method returns :data:`NotImplemented`, the
augmented assignment falls back to the normal methods. For instance, if *x*
is an instance of a class with an :meth:`__iadd__` method, ``x += y`` is
equivalent to ``x = x.__iadd__(y)`` . Otherwise, ``x.__add__(y)`` and
equivalent to ``x = x.__iadd__(y)`` . If :meth:`__iadd__` does not exist, or if ``x.__iadd__(y)``
returns :data:`!NotImplemented`, ``x.__add__(y)`` and
``y.__radd__(x)`` are considered, as with the evaluation of ``x + y``. In
certain situations, augmented assignment can result in unexpected errors (see
:ref:`faq-augmented-assignment-tuple-error`), but this behavior is in fact
Expand Down
31 changes: 24 additions & 7 deletions Doc/tutorial/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,6 @@ indexed and sliced::
>>> squares[-3:] # slicing returns a new list
[9, 16, 25]

All slice operations return a new list containing the requested elements. This
means that the following slice returns a
:ref:`shallow copy <shallow_vs_deep_copy>` of the list::

>>> squares[:]
[1, 4, 9, 16, 25]

Lists also support operations like concatenation::

>>> squares + [36, 49, 64, 81, 100]
Expand All @@ -435,6 +428,30 @@ the :meth:`!list.append` *method* (we will see more about methods later)::
>>> cubes
[1, 8, 27, 64, 125, 216, 343]

Simple assignment in Python never copies data. When you assign a list
to a variable, the variable refers to the *existing list*.
Any changes you make to the list through one variable will be seen
through all other variables that refer to it.::

>>> rgb = ["Red", "Green", "Blue"]
>>> rgba = rgb
>>> id(rgb) == id(rgba) # they reference the same object
True
>>> rgba.append("Alph")
>>> rgb
["Red", "Green", "Blue", "Alph"]

All slice operations return a new list containing the requested elements. This
means that the following slice returns a
:ref:`shallow copy <shallow_vs_deep_copy>` of the list::

>>> correct_rgba = rgba[:]
>>> correct_rgba[-1] = "Alpha"
>>> correct_rgba
["Red", "Green", "Blue", "Alpha"]
>>> rgba
["Red", "Green", "Blue", "Alph"]

Assignment to slices is also possible, and this can even change the size of the
list or clear it entirely::

Expand Down
Loading

0 comments on commit 4861d7d

Please sign in to comment.