Skip to content

Commit 25d3f5b

Browse files
committed
Merge remote-tracking branch 'upstream/main' into pythongh-107265
2 parents e38c553 + 4d43931 commit 25d3f5b

38 files changed

+3896
-1636
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ jobs:
244244
needs: check_source
245245
if: needs.check_source.outputs.run_tests == 'true'
246246
env:
247-
OPENSSL_VER: 1.1.1u
247+
OPENSSL_VER: 1.1.1v
248248
PYTHONSTRICTEXTENSIONBUILD: 1
249249
steps:
250250
- uses: actions/checkout@v3
@@ -313,7 +313,7 @@ jobs:
313313
strategy:
314314
fail-fast: false
315315
matrix:
316-
openssl_ver: [1.1.1u, 3.0.9, 3.1.1]
316+
openssl_ver: [1.1.1v, 3.0.10, 3.1.2]
317317
env:
318318
OPENSSL_VER: ${{ matrix.openssl_ver }}
319319
MULTISSL_DIR: ${{ github.workspace }}/multissl
@@ -365,7 +365,7 @@ jobs:
365365
needs: check_source
366366
if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true'
367367
env:
368-
OPENSSL_VER: 1.1.1u
368+
OPENSSL_VER: 1.1.1v
369369
PYTHONSTRICTEXTENSIONBUILD: 1
370370
steps:
371371
- uses: actions/checkout@v3
@@ -474,7 +474,7 @@ jobs:
474474
needs: check_source
475475
if: needs.check_source.outputs.run_tests == 'true'
476476
env:
477-
OPENSSL_VER: 1.1.1u
477+
OPENSSL_VER: 1.1.1v
478478
PYTHONSTRICTEXTENSIONBUILD: 1
479479
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
480480
steps:

.github/workflows/reusable-docs.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,30 @@ jobs:
1616
name: 'Docs'
1717
runs-on: ubuntu-latest
1818
timeout-minutes: 60
19+
env:
20+
branch_base: 'origin/${{ github.event.pull_request.base.ref }}'
21+
branch_pr: 'origin/${{ github.event.pull_request.head.ref }}'
22+
refspec_base: '+${{ github.event.pull_request.base.sha }}:remotes/origin/${{ github.event.pull_request.base.ref }}'
23+
refspec_pr: '+${{ github.event.pull_request.head.sha }}:remotes/origin/${{ github.event.pull_request.head.ref }}'
1924
steps:
20-
- uses: actions/checkout@v3
25+
- name: 'Check out latest PR branch commit'
26+
uses: actions/checkout@v3
27+
with:
28+
ref: ${{ github.event.pull_request.head.sha }}
29+
# Adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721
30+
- name: 'Fetch commits to get branch diff'
31+
run: |
32+
# Fetch enough history to find a common ancestor commit (aka merge-base):
33+
git fetch origin ${{ env.refspec_pr }} --depth=$(( ${{ github.event.pull_request.commits }} + 1 )) \
34+
--no-tags --prune --no-recurse-submodules
35+
36+
# This should get the oldest commit in the local fetched history (which may not be the commit the PR branched from):
37+
COMMON_ANCESTOR=$( git rev-list --first-parent --max-parents=0 --max-count=1 ${{ env.branch_pr }} )
38+
DATE=$( git log --date=iso8601 --format=%cd "${COMMON_ANCESTOR}" )
39+
40+
# Get all commits since that commit date from the base branch (eg: master or main):
41+
git fetch origin ${{ env.refspec_base }} --shallow-since="${DATE}" \
42+
--no-tags --prune --no-recurse-submodules
2143
- name: 'Set up Python'
2244
uses: actions/setup-python@v4
2345
with:
@@ -28,13 +50,6 @@ jobs:
2850
run: make -C Doc/ venv
2951

3052
# To annotate PRs with Sphinx nitpicks (missing references)
31-
- name: 'Get list of changed files'
32-
if: github.event_name == 'pull_request'
33-
id: changed_files
34-
uses: Ana06/[email protected]
35-
with:
36-
filter: "Doc/**"
37-
format: csv # works for paths with spaces
3853
- name: 'Build HTML documentation'
3954
continue-on-error: true
4055
run: |
@@ -45,7 +60,7 @@ jobs:
4560
if: github.event_name == 'pull_request'
4661
run: |
4762
python Doc/tools/check-warnings.py \
48-
--check-and-annotate '${{ steps.changed_files.outputs.added_modified }}' \
63+
--annotate-diff '${{ env.branch_base }}' '${{ env.branch_pr }}' \
4964
--fail-if-regression \
5065
--fail-if-improved
5166

Doc/howto/clinic.rst

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,54 +1941,70 @@ The generated docstring ends up looking like this:
19411941
19421942
19431943
.. _clinic-howto-deprecate-positional:
1944+
.. _clinic-howto-deprecate-keyword:
19441945

1945-
How to deprecate passing parameters positionally
1946-
------------------------------------------------
1946+
How to deprecate passing parameters positionally or by keyword
1947+
--------------------------------------------------------------
19471948

19481949
Argument Clinic provides syntax that makes it possible to generate code that
1949-
deprecates passing :term:`arguments <argument>` positionally.
1950+
deprecates passing :term:`arguments <argument>` for positional-or-keyword
1951+
:term:`parameters <parameter>` positionally or by keyword.
19501952
For example, say we've got a module-level function :py:func:`!foo.myfunc`
1951-
that has three :term:`parameters <parameter>`:
1952-
positional-or-keyword parameters *a* and *b*, and a keyword-only parameter *c*::
1953+
that has five parameters: a positional-only parameter *a*, three
1954+
positional-or-keyword parameters *b*, *c* and *d*, and a keyword-only
1955+
parameter *e*::
19531956

19541957
/*[clinic input]
19551958
module foo
19561959
myfunc
19571960
a: int
1961+
/
19581962
b: int
1959-
*
19601963
c: int
1964+
d: int
1965+
*
1966+
e: int
19611967
[clinic start generated output]*/
19621968

1963-
We now want to make the *b* parameter keyword-only;
1964-
however, we'll have to wait two releases before making this change,
1969+
We now want to make the *b* parameter positional-only and the *d* parameter
1970+
keyword-only;
1971+
however, we'll have to wait two releases before making these changes,
19651972
as mandated by Python's backwards-compatibility policy (see :pep:`387`).
19661973
For this example, imagine we're in the development phase for Python 3.12:
19671974
that means we'll be allowed to introduce deprecation warnings in Python 3.12
1968-
whenever the *b* parameter is passed positionally,
1969-
and we'll be allowed to make it keyword-only in Python 3.14 at the earliest.
1975+
whenever an argument for the *b* parameter is passed by keyword or an argument
1976+
for the *d* parameter is passed positionally, and we'll be allowed to make
1977+
them positional-only and keyword-only respectively in Python 3.14 at
1978+
the earliest.
19701979

19711980
We can use Argument Clinic to emit the desired deprecation warnings
1972-
using the ``* [from ...]`` syntax,
1973-
by adding the line ``* [from 3.14]`` right above the *b* parameter::
1981+
using the ``[from ...]`` syntax, by adding the line ``/ [from 3.14]`` right
1982+
below the *b* parameter and adding the line ``* [from 3.14]`` right above
1983+
the *d* parameter::
19741984

19751985
/*[clinic input]
19761986
module foo
19771987
myfunc
19781988
a: int
1979-
* [from 3.14]
1989+
/
19801990
b: int
1981-
*
1991+
/ [from 3.14]
19821992
c: int
1993+
* [from 3.14]
1994+
d: int
1995+
*
1996+
e: int
19831997
[clinic start generated output]*/
19841998

19851999
Next, regenerate Argument Clinic code (``make clinic``),
19862000
and add unit tests for the new behaviour.
19872001

19882002
The generated code will now emit a :exc:`DeprecationWarning`
1989-
when an :term:`argument` for the :term:`parameter` *b* is passed positionally.
2003+
when an :term:`argument` for the :term:`parameter` *d* is passed positionally
2004+
(e.g ``myfunc(1, 2, 3, 4, e=5)``) or an argument for the parameter *b* is
2005+
passed by keyword (e.g ``myfunc(1, b=2, c=3, d=4, e=5)``).
19902006
C preprocessor directives are also generated for emitting
1991-
compiler warnings if the ``* [from ...]`` line has not been removed
2007+
compiler warnings if the ``[from ...]`` lines have not been removed
19922008
from the Argument Clinic input when the deprecation period is over,
19932009
which means when the alpha phase of the specified Python version kicks in.
19942010

@@ -2001,21 +2017,26 @@ Luckily for us, compiler warnings are now generated:
20012017
.. code-block:: none
20022018
20032019
In file included from Modules/foomodule.c:139:
2004-
Modules/clinic/foomodule.c.h:139:8: warning: In 'foomodule.c', update parameter(s) 'a' and 'b' in the clinic input of 'mymod.myfunc' to be keyword-only. [-W#warnings]
2005-
# warning "In 'foomodule.c', update parameter(s) 'a' and 'b' in the clinic input of 'mymod.myfunc' to be keyword-only. [-W#warnings]"
2020+
Modules/clinic/foomodule.c.h:139:8: warning: In 'foomodule.c', update the clinic input of 'mymod.myfunc'. [-W#warnings]
2021+
# warning "In 'foomodule.c', update the clinic input of 'mymod.myfunc'. [-W#warnings]"
20062022
^
20072023
2008-
We now close the deprecation phase by making *b* keyword-only;
2009-
replace the ``* [from ...]`` line above *b*
2010-
with the ``*`` from the line above *c*::
2024+
We now close the deprecation phase by making *a* positional-only and *c*
2025+
keyword-only;
2026+
replace the ``/ [from ...]`` line below *b* with the ``/`` from the line
2027+
below *a* and the ``* [from ...]`` line above *d* with the ``*`` from
2028+
the line above *e*::
20112029

20122030
/*[clinic input]
20132031
module foo
20142032
myfunc
20152033
a: int
2016-
*
20172034
b: int
2035+
/
20182036
c: int
2037+
*
2038+
d: int
2039+
e: int
20192040
[clinic start generated output]*/
20202041

20212042
Finally, run ``make clinic`` to regenerate the Argument Clinic code,

Doc/library/asyncio-task.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,9 @@ Shielding From Cancellation
631631
Timeouts
632632
========
633633

634-
.. coroutinefunction:: timeout(delay)
634+
.. function:: timeout(delay)
635635

636-
An :ref:`asynchronous context manager <async-context-managers>`
636+
Return an :ref:`asynchronous context manager <async-context-managers>`
637637
that can be used to limit the amount of time spent waiting on
638638
something.
639639

@@ -724,7 +724,7 @@ Timeouts
724724

725725
.. versionadded:: 3.11
726726

727-
.. coroutinefunction:: timeout_at(when)
727+
.. function:: timeout_at(when)
728728

729729
Similar to :func:`asyncio.timeout`, except *when* is the absolute time
730730
to stop waiting, or ``None``.

Doc/library/ctypes.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,17 +2029,17 @@ Utility functions
20292029
specifying an address, or a ctypes instance.
20302030

20312031

2032-
.. function:: POINTER(type)
2032+
.. function:: POINTER(type, /)
20332033

2034-
This factory function creates and returns a new ctypes pointer type. Pointer
2035-
types are cached and reused internally, so calling this function repeatedly is
2036-
cheap. *type* must be a ctypes type.
2034+
Create and return a new ctypes pointer type. Pointer types are cached and
2035+
reused internally, so calling this function repeatedly is cheap.
2036+
*type* must be a ctypes type.
20372037

20382038

2039-
.. function:: pointer(obj)
2039+
.. function:: pointer(obj, /)
20402040

2041-
This function creates a new pointer instance, pointing to *obj*. The returned
2042-
object is of the type ``POINTER(type(obj))``.
2041+
Create a new pointer instance, pointing to *obj*.
2042+
The returned object is of the type ``POINTER(type(obj))``.
20432043

20442044
Note: If you just want to pass a pointer to an object to a foreign function
20452045
call, you should use ``byref(obj)`` which is much faster.

Doc/library/functools.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,9 @@ The :mod:`functools` module defines the following functions:
226226

227227
In general, the LRU cache should only be used when you want to reuse
228228
previously computed values. Accordingly, it doesn't make sense to cache
229-
functions with side-effects, functions that need to create distinct mutable
230-
objects on each call, or impure functions such as time() or random().
229+
functions with side-effects, functions that need to create
230+
distinct mutable objects on each call (such as generators and async functions),
231+
or impure functions such as time() or random().
231232

232233
Example of an LRU cache for static web content::
233234

Doc/library/itertools.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,9 +1048,7 @@ The following recipes have a more mathematical flavor:
10481048
# factor(1_000_000_000_000_007) --> 47 59 360620266859
10491049
# factor(1_000_000_000_000_403) --> 1000000000000403
10501050
for prime in sieve(math.isqrt(n) + 1):
1051-
while True:
1052-
if n % prime:
1053-
break
1051+
while not n % prime:
10541052
yield prime
10551053
n //= prime
10561054
if n == 1:

0 commit comments

Comments
 (0)