Skip to content

Commit 19b01c2

Browse files
authored
Merge branch 'main' into fix-issue-139686
2 parents e79e806 + a310b3a commit 19b01c2

File tree

120 files changed

+3009
-1095
lines changed

Some content is hidden

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

120 files changed

+3009
-1095
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -202,23 +202,15 @@ jobs:
202202
strategy:
203203
fail-fast: false
204204
matrix:
205-
# Cirrus and macos-14 are M1, macos-15-intel is default GHA Intel.
206-
# macOS 13 only runs tests against the GIL-enabled CPython.
207-
# Cirrus used for upstream, macos-14 for forks.
205+
# macos-14 is M1, macos-15-intel is Intel.
206+
# macos-15-intel only runs tests against the GIL-enabled CPython.
208207
os:
209-
- ghcr.io/cirruslabs/macos-runner:sonoma
210208
- macos-14
211209
- macos-15-intel
212-
is-fork: # only used for the exclusion trick
213-
- ${{ github.repository_owner != 'python' }}
214210
free-threading:
215211
- false
216212
- true
217213
exclude:
218-
- os: ghcr.io/cirruslabs/macos-runner:sonoma
219-
is-fork: true
220-
- os: macos-14
221-
is-fork: false
222214
- os: macos-15-intel
223215
free-threading: true
224216
uses: ./.github/workflows/reusable-macos.yml
@@ -409,9 +401,8 @@ jobs:
409401
fail-fast: false
410402
matrix:
411403
include:
412-
# Use the same runs-on configuration as build-macos and build-ubuntu.
413404
- arch: aarch64
414-
runs-on: ${{ github.repository_owner == 'python' && 'ghcr.io/cirruslabs/macos-runner:sonoma' || 'macos-14' }}
405+
runs-on: macos-14
415406
- arch: x86_64
416407
runs-on: ubuntu-24.04
417408

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ repos:
2626
name: Run Ruff (lint) on Tools/peg_generator/
2727
args: [--exit-non-zero-on-fix, --config=Tools/peg_generator/.ruff.toml]
2828
files: ^Tools/peg_generator/
29+
- id: ruff-check
30+
name: Run Ruff (lint) on Tools/wasm/
31+
args: [--exit-non-zero-on-fix, --config=Tools/wasm/.ruff.toml]
32+
files: ^Tools/wasm/
2933
- id: ruff-format
3034
name: Run Ruff (format) on Doc/
3135
args: [--check]
@@ -34,6 +38,10 @@ repos:
3438
name: Run Ruff (format) on Tools/build/check_warnings.py
3539
args: [--check, --config=Tools/build/.ruff.toml]
3640
files: ^Tools/build/check_warnings.py
41+
- id: ruff-format
42+
name: Run Ruff (format) on Tools/wasm/
43+
args: [--check, --config=Tools/wasm/.ruff.toml]
44+
files: ^Tools/wasm/
3745

3846
- repo: https://github.com/psf/black-pre-commit-mirror
3947
rev: 25.9.0

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ venv:
184184
fi
185185

186186
.PHONY: dist-no-html
187-
dist-no-html: dist-text dist-pdf dist-epub dist-texinfo
187+
dist-no-html: dist-text dist-epub dist-texinfo
188188

189189
.PHONY: dist
190190
dist:

Doc/c-api/init.rst

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ code, or when embedding the Python interpreter:
11131113
This function is safe to call without an :term:`attached thread state`; it
11141114
will simply return ``NULL`` indicating that there was no prior thread state.
11151115
1116-
.. seealso:
1116+
.. seealso::
11171117
:c:func:`PyEval_ReleaseThread`
11181118
11191119
.. note::
@@ -1124,6 +1124,19 @@ code, or when embedding the Python interpreter:
11241124
The following functions use thread-local storage, and are not compatible
11251125
with sub-interpreters:
11261126
1127+
.. c:type:: PyGILState_STATE
1128+
1129+
The type of the value returned by :c:func:`PyGILState_Ensure` and passed to
1130+
:c:func:`PyGILState_Release`.
1131+
1132+
.. c:enumerator:: PyGILState_LOCKED
1133+
1134+
The GIL was already held when :c:func:`PyGILState_Ensure` was called.
1135+
1136+
.. c:enumerator:: PyGILState_UNLOCKED
1137+
1138+
The GIL was not held when :c:func:`PyGILState_Ensure` was called.
1139+
11271140
.. c:function:: PyGILState_STATE PyGILState_Ensure()
11281141
11291142
Ensure that the current thread is ready to call the Python C API regardless
@@ -1174,12 +1187,12 @@ with sub-interpreters:
11741187
made on the main thread. This is mainly a helper/diagnostic function.
11751188
11761189
.. note::
1177-
This function does not account for :term:`thread states <thread state>` created
1178-
by something other than :c:func:`PyGILState_Ensure` (such as :c:func:`PyThreadState_New`).
1190+
This function may return non-``NULL`` even when the :term:`thread state`
1191+
is detached.
11791192
Prefer :c:func:`PyThreadState_Get` or :c:func:`PyThreadState_GetUnchecked`
11801193
for most cases.
11811194
1182-
.. seealso: :c:func:`PyThreadState_Get``
1195+
.. seealso:: :c:func:`PyThreadState_Get`
11831196
11841197
.. c:function:: int PyGILState_Check()
11851198
@@ -1278,11 +1291,11 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
12781291
must be :term:`attached <attached thread state>`
12791292
12801293
.. versionchanged:: 3.9
1281-
This function now calls the :c:member:`PyThreadState.on_delete` callback.
1294+
This function now calls the :c:member:`!PyThreadState.on_delete` callback.
12821295
Previously, that happened in :c:func:`PyThreadState_Delete`.
12831296
12841297
.. versionchanged:: 3.13
1285-
The :c:member:`PyThreadState.on_delete` callback was removed.
1298+
The :c:member:`!PyThreadState.on_delete` callback was removed.
12861299
12871300
12881301
.. c:function:: void PyThreadState_Delete(PyThreadState *tstate)

Doc/library/contextlib.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,10 @@ Functions and classes provided:
327327
.. function:: redirect_stdout(new_target)
328328

329329
Context manager for temporarily redirecting :data:`sys.stdout` to
330-
another file or file-like object.
330+
another :term:`file object`.
331331

332332
This tool adds flexibility to existing functions or classes whose output
333-
is hardwired to stdout.
333+
is hardwired to :data:`sys.stdout`.
334334

335335
For example, the output of :func:`help` normally is sent to *sys.stdout*.
336336
You can capture that output in a string by redirecting the output to an
@@ -366,8 +366,8 @@ Functions and classes provided:
366366

367367
.. function:: redirect_stderr(new_target)
368368

369-
Similar to :func:`~contextlib.redirect_stdout` but redirecting
370-
:data:`sys.stderr` to another file or file-like object.
369+
Similar to :func:`~contextlib.redirect_stdout` but redirecting the global
370+
:data:`sys.stderr` to another :term:`file object`.
371371

372372
This context manager is :ref:`reentrant <reentrant-cms>`.
373373

Doc/library/os.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ process and user.
216216

217217
You can delete items in this mapping to unset environment variables.
218218
:func:`unsetenv` will be called automatically when an item is deleted from
219-
:data:`os.environ`, and when one of the :meth:`pop` or :meth:`clear` methods is
220-
called.
219+
:data:`os.environ`, and when one of the :meth:`~dict.pop` or
220+
:meth:`~dict.clear` methods is called.
221221

222222
.. seealso::
223223

@@ -430,8 +430,8 @@ process and user.
430430
associated with the effective user id of the process; the group access
431431
list may change over the lifetime of the process, it is not affected by
432432
calls to :func:`setgroups`, and its length is not limited to 16. The
433-
deployment target value, :const:`MACOSX_DEPLOYMENT_TARGET`, can be
434-
obtained with :func:`sysconfig.get_config_var`.
433+
deployment target value can be obtained with
434+
:func:`sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') <sysconfig.get_config_var>`.
435435

436436

437437
.. function:: getlogin()
@@ -2606,10 +2606,10 @@ features:
26062606

26072607
Create a filesystem node (file, device special file or named pipe) named
26082608
*path*. *mode* specifies both the permissions to use and the type of node
2609-
to be created, being combined (bitwise OR) with one of ``stat.S_IFREG``,
2610-
``stat.S_IFCHR``, ``stat.S_IFBLK``, and ``stat.S_IFIFO`` (those constants are
2611-
available in :mod:`stat`). For ``stat.S_IFCHR`` and ``stat.S_IFBLK``,
2612-
*device* defines the newly created device special file (probably using
2609+
to be created, being combined (bitwise OR) with one of :const:`stat.S_IFREG`,
2610+
:const:`stat.S_IFCHR`, :const:`stat.S_IFBLK`, and :const:`stat.S_IFIFO`.
2611+
For :const:`stat.S_IFCHR` and :const:`stat.S_IFBLK`, *device* defines the
2612+
newly created device special file (probably using
26132613
:func:`os.makedev`), otherwise it is ignored.
26142614

26152615
This function can also support :ref:`paths relative to directory descriptors
@@ -2627,13 +2627,13 @@ features:
26272627
.. function:: major(device, /)
26282628

26292629
Extract the device major number from a raw device number (usually the
2630-
:attr:`st_dev` or :attr:`st_rdev` field from :c:struct:`stat`).
2630+
:attr:`~stat_result.st_dev` or :attr:`~stat_result.st_rdev` field from :c:struct:`stat`).
26312631

26322632

26332633
.. function:: minor(device, /)
26342634

26352635
Extract the device minor number from a raw device number (usually the
2636-
:attr:`st_dev` or :attr:`st_rdev` field from :c:struct:`stat`).
2636+
:attr:`~stat_result.st_dev` or :attr:`~stat_result.st_rdev` field from :c:struct:`stat`).
26372637

26382638

26392639
.. function:: makedev(major, minor, /)
@@ -3364,8 +3364,8 @@ features:
33643364

33653365
.. versionchanged:: 3.8
33663366
On Windows, the :attr:`st_mode` member now identifies special
3367-
files as :const:`S_IFCHR`, :const:`S_IFIFO` or :const:`S_IFBLK`
3368-
as appropriate.
3367+
files as :const:`~stat.S_IFCHR`, :const:`~stat.S_IFIFO` or
3368+
:const:`~stat.S_IFBLK` as appropriate.
33693369

33703370
.. versionchanged:: 3.12
33713371
On Windows, :attr:`st_ctime` is deprecated. Eventually, it will
@@ -4285,10 +4285,10 @@ to be ignored.
42854285

42864286
.. function:: abort()
42874287

4288-
Generate a :const:`SIGABRT` signal to the current process. On Unix, the default
4288+
Generate a :const:`~signal.SIGABRT` signal to the current process. On Unix, the default
42894289
behavior is to produce a core dump; on Windows, the process immediately returns
42904290
an exit code of ``3``. Be aware that calling this function will not call the
4291-
Python signal handler registered for :const:`SIGABRT` with
4291+
Python signal handler registered for :const:`~signal.SIGABRT` with
42924292
:func:`signal.signal`.
42934293

42944294

Doc/library/ssl.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,8 @@ Random generation
354354
.. function:: RAND_status()
355355

356356
Return ``True`` if the SSL pseudo-random number generator has been seeded
357-
with 'enough' randomness, and ``False`` otherwise. You can use
358-
:func:`ssl.RAND_egd` and :func:`ssl.RAND_add` to increase the randomness of
359-
the pseudo-random number generator.
357+
with 'enough' randomness, and ``False`` otherwise. Use :func:`ssl.RAND_add`
358+
to increase the randomness of the pseudo-random number generator.
360359

361360
.. function:: RAND_add(bytes, entropy, /)
362361

Doc/library/subprocess.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ functions.
649649

650650
If specified, *env* must provide any variables required for the program to
651651
execute. On Windows, in order to run a `side-by-side assembly`_ the
652-
specified *env* **must** include a valid :envvar:`SystemRoot`.
652+
specified *env* **must** include a valid ``%SystemRoot%``.
653653

654654
.. _side-by-side assembly: https://en.wikipedia.org/wiki/Side-by-Side_Assembly
655655

@@ -1473,7 +1473,7 @@ handling consistency are valid for these functions.
14731473

14741474
Return ``(exitcode, output)`` of executing *cmd* in a shell.
14751475

1476-
Execute the string *cmd* in a shell with :meth:`Popen.check_output` and
1476+
Execute the string *cmd* in a shell with :func:`check_output` and
14771477
return a 2-tuple ``(exitcode, output)``.
14781478
*encoding* and *errors* are used to decode output;
14791479
see the notes on :ref:`frequently-used-arguments` for more details.

Doc/reference/lexical_analysis.rst

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,76 @@ Lexical analysis
1010
A Python program is read by a *parser*. Input to the parser is a stream of
1111
:term:`tokens <token>`, generated by the *lexical analyzer* (also known as
1212
the *tokenizer*).
13-
This chapter describes how the lexical analyzer breaks a file into tokens.
13+
This chapter describes how the lexical analyzer produces these tokens.
1414

15-
Python reads program text as Unicode code points; the encoding of a source file
16-
can be given by an encoding declaration and defaults to UTF-8, see :pep:`3120`
17-
for details. If the source file cannot be decoded, a :exc:`SyntaxError` is
18-
raised.
15+
The lexical analyzer determines the program text's :ref:`encoding <encodings>`
16+
(UTF-8 by default), and decodes the text into
17+
:ref:`source characters <lexical-source-character>`.
18+
If the text cannot be decoded, a :exc:`SyntaxError` is raised.
19+
20+
Next, the lexical analyzer uses the source characters to generate a stream of tokens.
21+
The type of a generated token generally depends on the next source character to
22+
be processed. Similarly, other special behavior of the analyzer depends on
23+
the first source character that hasn't yet been processed.
24+
The following table gives a quick summary of these source characters,
25+
with links to sections that contain more information.
26+
27+
.. list-table::
28+
:header-rows: 1
29+
30+
* - Character
31+
- Next token (or other relevant documentation)
32+
33+
* - * space
34+
* tab
35+
* formfeed
36+
- * :ref:`Whitespace <whitespace>`
37+
38+
* - * CR, LF
39+
- * :ref:`New line <line-structure>`
40+
* :ref:`Indentation <indentation>`
41+
42+
* - * backslash (``\``)
43+
- * :ref:`Explicit line joining <explicit-joining>`
44+
* (Also significant in :ref:`string escape sequences <escape-sequences>`)
45+
46+
* - * hash (``#``)
47+
- * :ref:`Comment <comments>`
48+
49+
* - * quote (``'``, ``"``)
50+
- * :ref:`String literal <strings>`
51+
52+
* - * ASCII letter (``a``-``z``, ``A``-``Z``)
53+
* non-ASCII character
54+
- * :ref:`Name <identifiers>`
55+
* Prefixed :ref:`string or bytes literal <strings>`
56+
57+
* - * underscore (``_``)
58+
- * :ref:`Name <identifiers>`
59+
* (Can also be part of :ref:`numeric literals <numbers>`)
60+
61+
* - * number (``0``-``9``)
62+
- * :ref:`Numeric literal <numbers>`
63+
64+
* - * dot (``.``)
65+
- * :ref:`Numeric literal <numbers>`
66+
* :ref:`Operator <operators>`
67+
68+
* - * question mark (``?``)
69+
* dollar (``$``)
70+
*
71+
.. (the following uses zero-width space characters to render
72+
.. a literal backquote)
73+
74+
backquote (``​`​``)
75+
* control character
76+
- * Error (outside string literals and comments)
77+
78+
* - * other printing character
79+
- * :ref:`Operator or delimiter <operators>`
80+
81+
* - * end of file
82+
- * :ref:`End marker <endmarker-token>`
1983

2084

2185
.. _line-structure:
@@ -120,6 +184,8 @@ If an encoding is declared, the encoding name must be recognized by Python
120184
encoding is used for all lexical analysis, including string literals, comments
121185
and identifiers.
122186

187+
.. _lexical-source-character:
188+
123189
All lexical analysis, including string literals, comments
124190
and identifiers, works on Unicode text decoded using the source encoding.
125191
Any Unicode code point, except the NUL control character, can appear in

Doc/tools/.nitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
Doc/c-api/descriptor.rst
66
Doc/c-api/float.rst
7-
Doc/c-api/init.rst
87
Doc/c-api/init_config.rst
98
Doc/c-api/intro.rst
109
Doc/c-api/module.rst
@@ -35,7 +34,6 @@ Doc/library/smtplib.rst
3534
Doc/library/socket.rst
3635
Doc/library/ssl.rst
3736
Doc/library/stdtypes.rst
38-
Doc/library/subprocess.rst
3937
Doc/library/termios.rst
4038
Doc/library/test.rst
4139
Doc/library/tkinter.rst

0 commit comments

Comments
 (0)