Skip to content

Commit 4bf74b8

Browse files
committed
Merge branch 'main' into pythongh-126688-import-lock
2 parents 5e86cca + 25aee21 commit 4bf74b8

File tree

226 files changed

+5381
-2764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

226 files changed

+5381
-2764
lines changed

.github/workflows/jit.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- x86_64-pc-windows-msvc/msvc
5353
- aarch64-pc-windows-msvc/msvc
5454
- x86_64-apple-darwin/clang
55-
# - aarch64-apple-darwin/clang
55+
- aarch64-apple-darwin/clang
5656
- x86_64-unknown-linux-gnu/gcc
5757
- x86_64-unknown-linux-gnu/clang
5858
- aarch64-unknown-linux-gnu/gcc
@@ -79,11 +79,10 @@ jobs:
7979
architecture: x86_64
8080
runner: macos-13
8181
compiler: clang
82-
# GH-126464: A recent change to either GHA or LLVM broke this job:
83-
# - target: aarch64-apple-darwin/clang
84-
# architecture: aarch64
85-
# runner: macos-14
86-
# compiler: clang
82+
- target: aarch64-apple-darwin/clang
83+
architecture: aarch64
84+
runner: macos-14
85+
compiler: clang
8786
- target: x86_64-unknown-linux-gnu/gcc
8887
architecture: x86_64
8988
runner: ubuntu-22.04
@@ -132,8 +131,8 @@ jobs:
132131
brew update
133132
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
134133
brew install llvm@${{ matrix.llvm }}
135-
SDKROOT="$(xcrun --show-sdk-path)" \
136-
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
134+
export SDKROOT="$(xcrun --show-sdk-path)"
135+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
137136
make all --jobs 4
138137
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
139138

.github/workflows/reusable-wasi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
WASI_SDK_VERSION: 24
1818
WASI_SDK_PATH: /opt/wasi-sdk
1919
CROSS_BUILD_PYTHON: cross-build/build
20-
CROSS_BUILD_WASI: cross-build/wasm32-wasi
20+
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
2121
steps:
2222
- uses: actions/checkout@v4
2323
# No problem resolver registered as one doesn't currently exist for Clang.
@@ -31,7 +31,7 @@ jobs:
3131
with:
3232
path: ${{ env.WASI_SDK_PATH }}
3333
key: ${{ runner.os }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}
34-
- name: "Install WASI SDK"
34+
- name: "Install WASI SDK" # Hard-coded to x64.
3535
if: steps.cache-wasi-sdk.outputs.cache-hit != 'true'
3636
run: |
3737
mkdir ${{ env.WASI_SDK_PATH }} && \

Doc/c-api/typeobj.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,7 +2230,7 @@ This is done by filling a :c:type:`PyType_Spec` structure and calling
22302230
.. _number-structs:
22312231

22322232
Number Object Structures
2233-
========================
2233+
------------------------
22342234

22352235
.. sectionauthor:: Amaury Forgeot d'Arc
22362236

@@ -2344,7 +2344,7 @@ Number Object Structures
23442344
.. _mapping-structs:
23452345

23462346
Mapping Object Structures
2347-
=========================
2347+
-------------------------
23482348

23492349
.. sectionauthor:: Amaury Forgeot d'Arc
23502350

@@ -2381,7 +2381,7 @@ Mapping Object Structures
23812381
.. _sequence-structs:
23822382

23832383
Sequence Object Structures
2384-
==========================
2384+
--------------------------
23852385

23862386
.. sectionauthor:: Amaury Forgeot d'Arc
23872387

@@ -2461,7 +2461,7 @@ Sequence Object Structures
24612461
.. _buffer-structs:
24622462

24632463
Buffer Object Structures
2464-
========================
2464+
------------------------
24652465

24662466
.. sectionauthor:: Greg J. Stein <[email protected]>
24672467
.. sectionauthor:: Benjamin Peterson
@@ -2556,7 +2556,7 @@ Buffer Object Structures
25562556

25572557

25582558
Async Object Structures
2559-
=======================
2559+
-----------------------
25602560

25612561
.. sectionauthor:: Yury Selivanov <[email protected]>
25622562

@@ -2624,7 +2624,7 @@ Async Object Structures
26242624
.. _slot-typedefs:
26252625

26262626
Slot Type typedefs
2627-
==================
2627+
------------------
26282628

26292629
.. c:type:: PyObject *(*allocfunc)(PyTypeObject *cls, Py_ssize_t nitems)
26302630
@@ -2733,7 +2733,7 @@ Slot Type typedefs
27332733
.. _typedef-examples:
27342734

27352735
Examples
2736-
========
2736+
--------
27372737

27382738
The following are simple examples of Python type definitions. They
27392739
include common usage you may encounter. Some demonstrate tricky corner

Doc/deprecations/pending-removal-in-3.14.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
Pending removal in Python 3.14
22
------------------------------
33

4-
* The import system:
5-
6-
* Setting :attr:`~module.__loader__` on a module while
7-
failing to set :attr:`__spec__.loader <importlib.machinery.ModuleSpec.loader>`
8-
is deprecated. In Python 3.14, :attr:`!__loader__` will cease to be set or
9-
taken into consideration by the import system or the standard library.
10-
114
* :mod:`argparse`: The *type*, *choices*, and *metavar* parameters
125
of :class:`!argparse.BooleanOptionalAction` are deprecated
136
and will be removed in 3.14.

Doc/deprecations/pending-removal-in-3.16.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Pending removal in Python 3.16
22
------------------------------
33

4+
* The import system:
5+
6+
* Setting :attr:`~module.__loader__` on a module while
7+
failing to set :attr:`__spec__.loader <importlib.machinery.ModuleSpec.loader>`
8+
is deprecated. In Python 3.16, :attr:`!__loader__` will cease to be set or
9+
taken into consideration by the import system or the standard library.
10+
411
* :mod:`array`:
512

613
* The ``'u'`` format code (:c:type:`wchar_t`)

Doc/howto/logging-cookbook.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,11 +1267,8 @@ to adapt in your own applications.
12671267

12681268
You could also write your own handler which uses the :class:`~multiprocessing.Lock`
12691269
class from the :mod:`multiprocessing` module to serialize access to the
1270-
file from your processes. The existing :class:`FileHandler` and subclasses do
1271-
not make use of :mod:`multiprocessing` at present, though they may do so in the
1272-
future. Note that at present, the :mod:`multiprocessing` module does not provide
1273-
working lock functionality on all platforms (see
1274-
https://bugs.python.org/issue3770).
1270+
file from your processes. The stdlib :class:`FileHandler` and subclasses do
1271+
not make use of :mod:`multiprocessing`.
12751272

12761273
.. currentmodule:: logging.handlers
12771274

Doc/library/getopt.rst

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ exception:
3838
be parsed, without the leading reference to the running program. Typically, this
3939
means ``sys.argv[1:]``. *shortopts* is the string of option letters that the
4040
script wants to recognize, with options that require an argument followed by a
41-
colon (``':'``; i.e., the same format that Unix :c:func:`!getopt` uses).
41+
colon (``':'``) and options that accept an optional argument followed by
42+
two colons (``'::'``); i.e., the same format that Unix :c:func:`!getopt` uses.
4243

4344
.. note::
4445

@@ -49,8 +50,10 @@ exception:
4950
*longopts*, if specified, must be a list of strings with the names of the
5051
long options which should be supported. The leading ``'--'`` characters
5152
should not be included in the option name. Long options which require an
52-
argument should be followed by an equal sign (``'='``). Optional arguments
53-
are not supported. To accept only long options, *shortopts* should be an
53+
argument should be followed by an equal sign (``'='``).
54+
Long options which accept an optional argument should be followed by
55+
an equal sign and question mark (``'=?'``).
56+
To accept only long options, *shortopts* should be an
5457
empty string. Long options on the command line can be recognized so long as
5558
they provide a prefix of the option name that matches exactly one of the
5659
accepted options. For example, if *longopts* is ``['foo', 'frob']``, the
@@ -67,6 +70,9 @@ exception:
6770
options occur in the list in the same order in which they were found, thus
6871
allowing multiple occurrences. Long and short options may be mixed.
6972

73+
.. versionchanged:: 3.14
74+
Optional arguments are supported.
75+
7076

7177
.. function:: gnu_getopt(args, shortopts, longopts=[])
7278

@@ -124,6 +130,20 @@ Using long option names is equally easy:
124130
>>> args
125131
['a1', 'a2']
126132

133+
Optional arguments should be specified explicitly:
134+
135+
.. doctest::
136+
137+
>>> s = '-Con -C --color=off --color a1 a2'
138+
>>> args = s.split()
139+
>>> args
140+
['-Con', '-C', '--color=off', '--color', 'a1', 'a2']
141+
>>> optlist, args = getopt.getopt(args, 'C::', ['color=?'])
142+
>>> optlist
143+
[('-C', 'on'), ('-C', ''), ('--color', 'off'), ('--color', '')]
144+
>>> args
145+
['a1', 'a2']
146+
127147
In a script, typical usage is something like this:
128148

129149
.. testcode::

Doc/library/os.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4577,8 +4577,7 @@ written in Python, such as a mail server's external command delivery program.
45774577
only be sent to console processes which share a common console window,
45784578
e.g., some subprocesses. Any other value for *sig* will cause the process
45794579
to be unconditionally killed by the TerminateProcess API, and the exit code
4580-
will be set to *sig*. The Windows version of :func:`kill` additionally takes
4581-
process handles to be killed.
4580+
will be set to *sig*.
45824581

45834582
See also :func:`signal.pthread_kill`.
45844583

Doc/library/typing.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,11 +1726,11 @@ without the dedicated syntax, as documented below.
17261726
class Sequence[T]: # T is a TypeVar
17271727
...
17281728

1729-
This syntax can also be used to create bound and constrained type
1729+
This syntax can also be used to create bounded and constrained type
17301730
variables::
17311731

1732-
class StrSequence[S: str]: # S is a TypeVar bound to str
1733-
...
1732+
class StrSequence[S: str]: # S is a TypeVar with a `str` upper bound;
1733+
... # we can say that S is "bounded by `str`"
17341734

17351735

17361736
class StrOrBytesSequence[A: (str, bytes)]: # A is a TypeVar constrained to str or bytes
@@ -1763,8 +1763,8 @@ without the dedicated syntax, as documented below.
17631763
"""Add two strings or bytes objects together."""
17641764
return x + y
17651765

1766-
Note that type variables can be *bound*, *constrained*, or neither, but
1767-
cannot be both bound *and* constrained.
1766+
Note that type variables can be *bounded*, *constrained*, or neither, but
1767+
cannot be both bounded *and* constrained.
17681768

17691769
The variance of type variables is inferred by type checkers when they are created
17701770
through the :ref:`type parameter syntax <type-params>` or when
@@ -1774,8 +1774,8 @@ without the dedicated syntax, as documented below.
17741774
By default, manually created type variables are invariant.
17751775
See :pep:`484` and :pep:`695` for more details.
17761776

1777-
Bound type variables and constrained type variables have different
1778-
semantics in several important ways. Using a *bound* type variable means
1777+
Bounded type variables and constrained type variables have different
1778+
semantics in several important ways. Using a *bounded* type variable means
17791779
that the ``TypeVar`` will be solved using the most specific type possible::
17801780

17811781
x = print_capitalized('a string')
@@ -1789,8 +1789,8 @@ without the dedicated syntax, as documented below.
17891789

17901790
z = print_capitalized(45) # error: int is not a subtype of str
17911791

1792-
Type variables can be bound to concrete types, abstract types (ABCs or
1793-
protocols), and even unions of types::
1792+
The upper bound of a type variable can be a concrete type, abstract type
1793+
(ABC or Protocol), or even a union of types::
17941794

17951795
# Can be anything with an __abs__ method
17961796
def print_abs[T: SupportsAbs](arg: T) -> None:
@@ -1834,7 +1834,7 @@ without the dedicated syntax, as documented below.
18341834

18351835
.. attribute:: __bound__
18361836

1837-
The bound of the type variable, if any.
1837+
The upper bound of the type variable, if any.
18381838

18391839
.. versionchanged:: 3.12
18401840

@@ -2100,7 +2100,7 @@ without the dedicated syntax, as documented below.
21002100
return x + y
21012101

21022102
Without ``ParamSpec``, the simplest way to annotate this previously was to
2103-
use a :class:`TypeVar` with bound ``Callable[..., Any]``. However this
2103+
use a :class:`TypeVar` with upper bound ``Callable[..., Any]``. However this
21042104
causes two problems:
21052105

21062106
1. The type checker can't type check the ``inner`` function because

Doc/reference/compound_stmts.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,18 +534,15 @@ is semantically equivalent to::
534534
enter = type(manager).__enter__
535535
exit = type(manager).__exit__
536536
value = enter(manager)
537-
hit_except = False
538537

539538
try:
540539
TARGET = value
541540
SUITE
542541
except:
543-
hit_except = True
544542
if not exit(manager, *sys.exc_info()):
545543
raise
546-
finally:
547-
if not hit_except:
548-
exit(manager, None, None, None)
544+
else:
545+
exit(manager, None, None, None)
549546

550547
With more than one item, the context managers are processed as if multiple
551548
:keyword:`with` statements were nested::

Doc/reference/datamodel.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,9 +1028,9 @@ this approach.
10281028
using the :class:`types.ModuleType` constructor.
10291029
Previously the attribute was optional.
10301030

1031-
.. deprecated-removed:: 3.12 3.14
1031+
.. deprecated-removed:: 3.12 3.16
10321032
Setting :attr:`!__loader__` on a module while failing to set
1033-
:attr:`!__spec__.loader` is deprecated. In Python 3.14,
1033+
:attr:`!__spec__.loader` is deprecated. In Python 3.16,
10341034
:attr:`!__loader__` will cease to be set or taken into consideration by
10351035
the import system or the standard library.
10361036

Doc/using/configure.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,19 @@ General Options
297297

298298
.. versionadded:: 3.13
299299

300+
.. option:: --enable-experimental-jit=[no|yes|yes-off|interpreter]
301+
302+
Indicate how to integrate the :ref:`JIT compiler <whatsnew313-jit-compiler>`.
303+
304+
* ``no`` - build the interpreter without the JIT.
305+
* ``yes`` - build the interpreter with the JIT.
306+
* ``yes-off`` - build the interpreter with the JIT but disable it by default.
307+
* ``interpreter`` - build the interpreter without the JIT, but with the tier 2 enabled interpreter.
308+
309+
By convention, ``--enable-experimental-jit`` is a shorthand for ``--enable-experimental-jit=yes``.
310+
311+
.. versionadded:: 3.13
312+
300313
.. option:: PKG_CONFIG
301314

302315
Path to ``pkg-config`` utility.

Doc/whatsnew/3.14.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,11 @@ functools
314314
to reserve a place for positional arguments.
315315
(Contributed by Dominykas Grigonis in :gh:`119127`.)
316316

317+
getopt
318+
------
319+
320+
* Add support for options with optional arguments.
321+
(Contributed by Serhiy Storchaka in :gh:`126374`.)
317322

318323
http
319324
----

Doc/whatsnew/3.8.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ Add option ``--json-lines`` to parse every input line as a separate JSON object.
936936
logging
937937
-------
938938

939-
Added a *force* keyword argument to :func:`logging.basicConfig`
939+
Added a *force* keyword argument to :func:`logging.basicConfig`.
940940
When set to true, any existing handlers attached
941941
to the root logger are removed and closed before carrying out the
942942
configuration specified by the other arguments.

0 commit comments

Comments
 (0)