Skip to content

Commit 44c8fe2

Browse files
Merge branch 'main' into gh-108009
2 parents ffd95c6 + 17b3bc9 commit 44c8fe2

File tree

103 files changed

+1822
-556
lines changed

Some content is hidden

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

103 files changed

+1822
-556
lines changed

.github/workflows/jit.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,15 @@ jobs:
110110
- name: Native Windows
111111
if: runner.os == 'Windows' && matrix.architecture != 'ARM64'
112112
run: |
113-
choco upgrade llvm -y
114-
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
113+
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
115114
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '--pgo' }} -p ${{ matrix.architecture }}
116115
./PCbuild/rt.bat ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
117116
118117
# No PGO or tests (yet):
119118
- name: Emulated Windows
120119
if: runner.os == 'Windows' && matrix.architecture == 'ARM64'
121120
run: |
122-
choco upgrade llvm -y
123-
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
121+
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
124122
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
125123
126124
- name: Native macOS

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ repos:
1010
name: Run Ruff (lint) on Lib/test/
1111
args: [--exit-non-zero-on-fix]
1212
files: ^Lib/test/
13+
- id: ruff
14+
name: Run Ruff (lint) on Tools/build/check_warnings.py
15+
args: [--exit-non-zero-on-fix, --config=Tools/build/.ruff.toml]
16+
files: ^Tools/build/check_warnings.py
1317
- id: ruff
1418
name: Run Ruff (lint) on Argument Clinic
1519
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
@@ -22,6 +26,11 @@ repos:
2226
- repo: https://github.com/psf/black-pre-commit-mirror
2327
rev: 24.8.0
2428
hooks:
29+
- id: black
30+
name: Run Black on Tools/build/check_warnings.py
31+
files: ^Tools/build/check_warnings.py
32+
language_version: python3.12
33+
args: [--line-length=79]
2534
- id: black
2635
name: Run Black on Tools/jit/
2736
files: ^Tools/jit/

Android/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
# Python for Android
22

33
These instructions are only needed if you're planning to compile Python for
4-
Android yourself. Most users should *not* need to do this. If you're looking to
5-
use Python on Android, one of the following tools will provide a much more
6-
approachable user experience:
7-
8-
* [Briefcase](https://briefcase.readthedocs.io), from the BeeWare project
9-
* [Buildozer](https://buildozer.readthedocs.io), from the Kivy project
10-
* [Chaquopy](https://chaquo.com/chaquopy/)
4+
Android yourself. Most users should *not* need to do this. Instead, use one of
5+
the tools listed in `Doc/using/android.rst`, which will provide a much easier
6+
experience.
117

128

139
## Prerequisites
@@ -89,10 +85,10 @@ The test suite can be run on Linux, macOS, or Windows:
8985
The test suite can usually be run on a device with 2 GB of RAM, but this is
9086
borderline, so you may need to increase it to 4 GB. As of Android
9187
Studio Koala, 2 GB is the default for all emulators, although the user interface
92-
may indicate otherwise. The effective setting is `hw.ramSize` in
93-
~/.android/avd/*.avd/hardware-qemu.ini, whereas Android Studio displays the
94-
value from config.ini. Changing the value in Android Studio will update both of
95-
these files.
88+
may indicate otherwise. Locate the emulator's directory under `~/.android/avd`,
89+
and find `hw.ramSize` in both config.ini and hardware-qemu.ini. Either set these
90+
manually to the same value, or use the Android Studio Device Manager, which will
91+
update both files.
9692

9793
Before running the test suite, follow the instructions in the previous section
9894
to build the architecture you want to test. Then run the test script in one of
@@ -133,3 +129,8 @@ Every time you run `android.py test`, changes in pure-Python files in the
133129
repository's `Lib` directory will be picked up immediately. Changes in C files,
134130
and architecture-specific files such as sysconfigdata, will not take effect
135131
until you re-run `android.py make-host` or `build`.
132+
133+
134+
## Using in your own app
135+
136+
See `Doc/using/android.rst`.

Doc/c-api/contextvars.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,52 @@ Context object management functions:
101101
current context for the current thread. Returns ``0`` on success,
102102
and ``-1`` on error.
103103
104+
.. c:function:: int PyContext_AddWatcher(PyContext_WatchCallback callback)
105+
106+
Register *callback* as a context object watcher for the current interpreter.
107+
Return an ID which may be passed to :c:func:`PyContext_ClearWatcher`.
108+
In case of error (e.g. no more watcher IDs available),
109+
return ``-1`` and set an exception.
110+
111+
.. versionadded:: 3.14
112+
113+
.. c:function:: int PyContext_ClearWatcher(int watcher_id)
114+
115+
Clear watcher identified by *watcher_id* previously returned from
116+
:c:func:`PyContext_AddWatcher` for the current interpreter.
117+
Return ``0`` on success, or ``-1`` and set an exception on error
118+
(e.g. if the given *watcher_id* was never registered.)
119+
120+
.. versionadded:: 3.14
121+
122+
.. c:type:: PyContextEvent
123+
124+
Enumeration of possible context object watcher events:
125+
- ``Py_CONTEXT_EVENT_ENTER``
126+
- ``Py_CONTEXT_EVENT_EXIT``
127+
128+
.. versionadded:: 3.14
129+
130+
.. c:type:: int (*PyContext_WatchCallback)(PyContextEvent event, PyContext* ctx)
131+
132+
Type of a context object watcher callback function.
133+
If *event* is ``Py_CONTEXT_EVENT_ENTER``, then the callback is invoked
134+
after *ctx* has been set as the current context for the current thread.
135+
Otherwise, the callback is invoked before the deactivation of *ctx* as the current context
136+
and the restoration of the previous contex object for the current thread.
137+
138+
If the callback returns with an exception set, it must return ``-1``; this
139+
exception will be printed as an unraisable exception using
140+
:c:func:`PyErr_FormatUnraisable`. Otherwise it should return ``0``.
141+
142+
There may already be a pending exception set on entry to the callback. In
143+
this case, the callback should return ``0`` with the same exception still
144+
set. This means the callback may not call any other API that can set an
145+
exception unless it saves and clears the exception state first, and restores
146+
it before returning.
147+
148+
.. versionadded:: 3.14
149+
104150
105151
Context variable functions:
106152

Doc/data/stable_abi.dat

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/includes/wasm-ios-notavail.rst

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. include for modules that don't work on WASM or mobile platforms
2+
3+
.. availability:: not Android, not iOS, not WASI.
4+
5+
This module is not supported on :ref:`mobile platforms <mobile-availability>`
6+
or :ref:`WebAssembly platforms <wasm-availability>`.

Doc/library/argparse.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,12 @@ The following sections describe how each of these are used.
249249
prog
250250
^^^^
251251

252-
By default, :class:`ArgumentParser` objects use ``sys.argv[0]`` to determine
252+
By default, :class:`ArgumentParser` objects use the base name
253+
(see :func:`os.path.basename`) of ``sys.argv[0]`` to determine
253254
how to display the name of the program in help messages. This default is almost
254-
always desirable because it will make the help messages match how the program was
255-
invoked on the command line. For example, consider a file named
256-
``myprogram.py`` with the following code::
255+
always desirable because it will make the help messages match the name that was
256+
used to invoke the program on the command line. For example, consider a file
257+
named ``myprogram.py`` with the following code::
257258

258259
import argparse
259260
parser = argparse.ArgumentParser()
@@ -1122,6 +1123,9 @@ is used when no command-line argument was present::
11221123
>>> parser.parse_args([])
11231124
Namespace(foo=42)
11241125

1126+
For required_ arguments, the ``default`` value is ignored. For example, this
1127+
applies to positional arguments with nargs_ values other than ``?`` or ``*``,
1128+
or optional arguments marked as ``required=True``.
11251129

11261130
Providing ``default=argparse.SUPPRESS`` causes no attribute to be added if the
11271131
command-line argument was not present::

Doc/library/collections.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,8 +1169,11 @@ Some differences from :class:`dict` still remain:
11691169
In addition to the usual mapping methods, ordered dictionaries also support
11701170
reverse iteration using :func:`reversed`.
11711171

1172+
.. _collections_OrderedDict__eq__:
1173+
11721174
Equality tests between :class:`OrderedDict` objects are order-sensitive
1173-
and are implemented as ``list(od1.items())==list(od2.items())``.
1175+
and are roughly equivalent to ``list(od1.items())==list(od2.items())``.
1176+
11741177
Equality tests between :class:`OrderedDict` objects and other
11751178
:class:`~collections.abc.Mapping` objects are order-insensitive like regular
11761179
dictionaries. This allows :class:`OrderedDict` objects to be substituted
@@ -1186,7 +1189,7 @@ anywhere a regular dictionary is used.
11861189
method.
11871190

11881191
.. versionchanged:: 3.9
1189-
Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`.
1192+
Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`.
11901193

11911194

11921195
:class:`OrderedDict` Examples and Recipes

Doc/library/ctypes.rst

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,6 +2499,8 @@ Structured data types
24992499

25002500
Abstract base class for unions in native byte order.
25012501

2502+
Unions share common attributes and behavior with structures;
2503+
see :class:`Structure` documentation for details.
25022504

25032505
.. class:: BigEndianUnion(*args, **kw)
25042506

@@ -2558,14 +2560,19 @@ fields, or any other data types containing pointer type fields.
25582560
...
25592561
]
25602562

2561-
The :attr:`_fields_` class variable must, however, be defined before the
2562-
type is first used (an instance is created, :func:`sizeof` is called on it,
2563-
and so on). Later assignments to the :attr:`_fields_` class variable will
2564-
raise an AttributeError.
2563+
The :attr:`!_fields_` class variable can only be set once.
2564+
Later assignments will raise an :exc:`AttributeError`.
25652565

2566-
It is possible to define sub-subclasses of structure types, they inherit
2567-
the fields of the base class plus the :attr:`_fields_` defined in the
2568-
sub-subclass, if any.
2566+
Additionally, the :attr:`!_fields_` class variable must be defined before
2567+
the structure or union type is first used: an instance or subclass is
2568+
created, :func:`sizeof` is called on it, and so on.
2569+
Later assignments to :attr:`!_fields_` will raise an :exc:`AttributeError`.
2570+
If :attr:`!_fields_` has not been set before such use,
2571+
the structure or union will have no own fields, as if :attr:`!_fields_`
2572+
was empty.
2573+
2574+
Sub-subclasses of structure types inherit the fields of the base class
2575+
plus the :attr:`_fields_` defined in the sub-subclass, if any.
25692576

25702577

25712578
.. attribute:: _pack_

0 commit comments

Comments
 (0)