Skip to content

Commit e14e009

Browse files
Merge branch 'main' into fix-argparse-const-doc
2 parents d3e0e0b + 299de38 commit e14e009

File tree

515 files changed

+35085
-26103
lines changed

Some content is hidden

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

515 files changed

+35085
-26103
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,4 @@ Python/stdlib_module_names.h generated
103103
Tools/peg_generator/pegen/grammar_parser.py generated
104104
aclocal.m4 generated
105105
configure generated
106+
*.min.js generated

.github/CODEOWNERS

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ Tools/patchcheck/ @AA-Turner
8080
# ----------------------------------------------------------------------------
8181

8282
# Autotools
83-
configure* @erlend-aasland @corona10 @AA-Turner
84-
Makefile.pre.in @erlend-aasland @AA-Turner
85-
Modules/Setup* @erlend-aasland @AA-Turner
83+
configure* @erlend-aasland @corona10 @AA-Turner @emmatyping
84+
Makefile.pre.in @erlend-aasland @AA-Turner @emmatyping
85+
Modules/makesetup @erlend-aasland @AA-Turner @emmatyping
86+
Modules/Setup* @erlend-aasland @AA-Turner @emmatyping
8687
Tools/build/regen-configure.sh @AA-Turner
8788

8889

@@ -157,16 +158,16 @@ Lib/_osx_support.py @python/macos-team
157158
Lib/test/test__osx_support.py @python/macos-team
158159

159160
# WebAssembly
160-
Tools/wasm/README.md @brettcannon @freakboy3742
161+
Tools/wasm/README.md @brettcannon @freakboy3742 @emmatyping
161162

162163
# WebAssembly (Emscripten)
163-
Tools/wasm/config.site-wasm32-emscripten @freakboy3742
164-
Tools/wasm/emscripten @freakboy3742
164+
Tools/wasm/config.site-wasm32-emscripten @freakboy3742 @emmatyping
165+
Tools/wasm/emscripten @freakboy3742 @emmatyping
165166

166167
# WebAssembly (WASI)
167-
Tools/wasm/wasi-env @brettcannon
168-
Tools/wasm/wasi.py @brettcannon
169-
Tools/wasm/wasi @brettcannon
168+
Tools/wasm/wasi-env @brettcannon @emmatyping
169+
Tools/wasm/wasi.py @brettcannon @emmatyping
170+
Tools/wasm/wasi @brettcannon @emmatyping
170171

171172
# Windows
172173
PC/ @python/windows-team
@@ -603,9 +604,9 @@ Lib/test/test_zipfile/_path/ @jaraco
603604
Lib/zipfile/_path/ @jaraco
604605

605606
# Zstandard
606-
Lib/compression/zstd/ @AA-Turner
607-
Lib/test/test_zstd.py @AA-Turner
608-
Modules/_zstd/ @AA-Turner
607+
Lib/compression/zstd/ @AA-Turner @emmatyping
608+
Lib/test/test_zstd.py @AA-Turner @emmatyping
609+
Modules/_zstd/ @AA-Turner @emmatyping
609610

610611
# ----------------------------------------------------------------------------
611612

.github/workflows/jit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ jobs:
7272
include:
7373
- target: i686-pc-windows-msvc/msvc
7474
architecture: Win32
75-
runner: windows-latest
75+
runner: windows-2022
7676
- target: x86_64-pc-windows-msvc/msvc
7777
architecture: x64
78-
runner: windows-latest
78+
runner: windows-2022
7979
- target: aarch64-pc-windows-msvc/msvc
8080
architecture: ARM64
8181
runner: windows-11-arm

.github/workflows/reusable-windows-msi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
jobs:
1818
build:
1919
name: installer for ${{ inputs.arch }}
20-
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-latest' }}
20+
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2022' }}
2121
timeout-minutes: 60
2222
env:
2323
ARCH: ${{ inputs.arch }}

.github/workflows/reusable-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ env:
2121
jobs:
2222
build:
2323
name: Build and test (${{ inputs.arch }})
24-
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-latest' }}
24+
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2022' }}
2525
timeout-minutes: 60
2626
env:
2727
ARCH: ${{ inputs.arch }}

.github/workflows/tail-call.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ jobs:
4949
include:
5050
# - target: i686-pc-windows-msvc/msvc
5151
# architecture: Win32
52-
# runner: windows-latest
52+
# runner: windows-2022
5353
- target: x86_64-pc-windows-msvc/msvc
5454
architecture: x64
55-
runner: windows-latest
55+
runner: windows-2022
5656
# - target: aarch64-pc-windows-msvc/msvc
5757
# architecture: ARM64
58-
# runner: windows-latest
58+
# runner: windows-2022
5959
- target: x86_64-apple-darwin/clang
6060
architecture: x86_64
6161
runner: macos-13

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ repos:
2222
name: Run Ruff (lint) on Argument Clinic
2323
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
2424
files: ^Tools/clinic/|Lib/test/test_clinic.py
25+
- id: ruff
26+
name: Run Ruff (lint) on Tools/peg_generator/
27+
args: [--exit-non-zero-on-fix, --config=Tools/peg_generator/.ruff.toml]
28+
files: ^Tools/peg_generator/
2529
- id: ruff-format
2630
name: Run Ruff (format) on Doc/
2731
args: [--check]

Android/android.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,10 @@ def ci(context):
737737
# Prove the package is self-contained by using it to run the tests.
738738
shutil.unpack_archive(package_path, temp_dir)
739739

740-
# Arguments are similar to --fast-ci, but in single-process mode.
740+
# Randomization is disabled because order-dependent failures are
741+
# much less likely to pass on a rerun in single-process mode.
741742
launcher_args = ["--managed", "maxVersion", "-v"]
742-
test_args = [
743-
"--single-process", "--fail-env-changed", "--rerun", "--slowest",
744-
"--verbose3", "-u", "all,-cpu", "--timeout=600"
745-
]
743+
test_args = ["--fast-ci", "--single-process", "--no-randomize"]
746744
run(
747745
["./android.py", "test", *launcher_args, "--", *test_args],
748746
cwd=temp_dir

Doc/c-api/bytes.rst

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ called with a non-bytes parameter.
4747
*len* on success, and ``NULL`` on failure. If *v* is ``NULL``, the contents of
4848
the bytes object are uninitialized.
4949
50+
.. deprecated:: 3.15
51+
``PyBytes_FromStringAndSize(NULL, len)`` is :term:`soft deprecated`,
52+
use the :c:type:`PyBytesWriter` API instead.
53+
5054
5155
.. c:function:: PyObject* PyBytes_FromFormat(const char *format, ...)
5256
@@ -219,3 +223,168 @@ called with a non-bytes parameter.
219223
reallocation fails, the original bytes object at *\*bytes* is deallocated,
220224
*\*bytes* is set to ``NULL``, :exc:`MemoryError` is set, and ``-1`` is
221225
returned.
226+
227+
.. deprecated:: 3.15
228+
The function is :term:`soft deprecated`,
229+
use the :c:type:`PyBytesWriter` API instead.
230+
231+
.. _pybyteswriter:
232+
233+
PyBytesWriter
234+
-------------
235+
236+
The :c:type:`PyBytesWriter` API can be used to create a Python :class:`bytes`
237+
object.
238+
239+
.. versionadded:: next
240+
241+
.. c:type:: PyBytesWriter
242+
243+
A bytes writer instance.
244+
245+
The API is **not thread safe**: a writer should only be used by a single
246+
thread at the same time.
247+
248+
The instance must be destroyed by :c:func:`PyBytesWriter_Finish` on
249+
success, or :c:func:`PyBytesWriter_Discard` on error.
250+
251+
252+
Create, Finish, Discard
253+
^^^^^^^^^^^^^^^^^^^^^^^
254+
255+
.. c:function:: PyBytesWriter* PyBytesWriter_Create(Py_ssize_t size)
256+
257+
Create a :c:type:`PyBytesWriter` to write *size* bytes.
258+
259+
If *size* is greater than zero, allocate *size* bytes, and set the
260+
writer size to *size*. The caller is responsible to write *size*
261+
bytes using :c:func:`PyBytesWriter_GetData`.
262+
263+
On error, set an exception and return NULL.
264+
265+
*size* must be positive or zero.
266+
267+
.. c:function:: PyObject* PyBytesWriter_Finish(PyBytesWriter *writer)
268+
269+
Finish a :c:type:`PyBytesWriter` created by
270+
:c:func:`PyBytesWriter_Create`.
271+
272+
On success, return a Python :class:`bytes` object.
273+
On error, set an exception and return ``NULL``.
274+
275+
The writer instance is invalid after the call in any case.
276+
No API can be called on the writer after :c:func:`PyBytesWriter_Finish`.
277+
278+
.. c:function:: PyObject* PyBytesWriter_FinishWithSize(PyBytesWriter *writer, Py_ssize_t size)
279+
280+
Similar to :c:func:`PyBytesWriter_Finish`, but resize the writer
281+
to *size* bytes before creating the :class:`bytes` object.
282+
283+
.. c:function:: PyObject* PyBytesWriter_FinishWithPointer(PyBytesWriter *writer, void *buf)
284+
285+
Similar to :c:func:`PyBytesWriter_Finish`, but resize the writer
286+
using *buf* pointer before creating the :class:`bytes` object.
287+
288+
Set an exception and return ``NULL`` if *buf* pointer is outside the
289+
internal buffer bounds.
290+
291+
Function pseudo-code::
292+
293+
Py_ssize_t size = (char*)buf - (char*)PyBytesWriter_GetData(writer);
294+
return PyBytesWriter_FinishWithSize(writer, size);
295+
296+
.. c:function:: void PyBytesWriter_Discard(PyBytesWriter *writer)
297+
298+
Discard a :c:type:`PyBytesWriter` created by :c:func:`PyBytesWriter_Create`.
299+
300+
Do nothing if *writer* is ``NULL``.
301+
302+
The writer instance is invalid after the call.
303+
No API can be called on the writer after :c:func:`PyBytesWriter_Discard`.
304+
305+
High-level API
306+
^^^^^^^^^^^^^^
307+
308+
.. c:function:: int PyBytesWriter_WriteBytes(PyBytesWriter *writer, const void *bytes, Py_ssize_t size)
309+
310+
Grow the *writer* internal buffer by *size* bytes,
311+
write *size* bytes of *bytes* at the *writer* end,
312+
and add *size* to the *writer* size.
313+
314+
If *size* is equal to ``-1``, call ``strlen(bytes)`` to get the
315+
string length.
316+
317+
On success, return ``0``.
318+
On error, set an exception and return ``-1``.
319+
320+
.. c:function:: int PyBytesWriter_Format(PyBytesWriter *writer, const char *format, ...)
321+
322+
Similar to :c:func:`PyBytes_FromFormat`, but write the output directly at
323+
the writer end. Grow the writer internal buffer on demand. Then add the
324+
written size to the writer size.
325+
326+
On success, return ``0``.
327+
On error, set an exception and return ``-1``.
328+
329+
330+
Getters
331+
^^^^^^^
332+
333+
.. c:function:: Py_ssize_t PyBytesWriter_GetSize(PyBytesWriter *writer)
334+
335+
Get the writer size.
336+
337+
.. c:function:: void* PyBytesWriter_GetData(PyBytesWriter *writer)
338+
339+
Get the writer data: start of the internal buffer.
340+
341+
The pointer is valid until :c:func:`PyBytesWriter_Finish` or
342+
:c:func:`PyBytesWriter_Discard` is called on *writer*.
343+
344+
345+
Low-level API
346+
^^^^^^^^^^^^^
347+
348+
.. c:function:: int PyBytesWriter_Resize(PyBytesWriter *writer, Py_ssize_t size)
349+
350+
Resize the writer to *size* bytes. It can be used to enlarge or to
351+
shrink the writer.
352+
353+
Newly allocated bytes are left uninitialized.
354+
355+
On success, return ``0``.
356+
On error, set an exception and return ``-1``.
357+
358+
*size* must be positive or zero.
359+
360+
.. c:function:: int PyBytesWriter_Grow(PyBytesWriter *writer, Py_ssize_t grow)
361+
362+
Resize the writer by adding *grow* bytes to the current writer size.
363+
364+
Newly allocated bytes are left uninitialized.
365+
366+
On success, return ``0``.
367+
On error, set an exception and return ``-1``.
368+
369+
*size* can be negative to shrink the writer.
370+
371+
.. c:function:: void* PyBytesWriter_GrowAndUpdatePointer(PyBytesWriter *writer, Py_ssize_t size, void *buf)
372+
373+
Similar to :c:func:`PyBytesWriter_Grow`, but update also the *buf*
374+
pointer.
375+
376+
The *buf* pointer is moved if the internal buffer is moved in memory.
377+
The *buf* relative position within the internal buffer is left
378+
unchanged.
379+
380+
On error, set an exception and return ``NULL``.
381+
382+
*buf* must not be ``NULL``.
383+
384+
Function pseudo-code::
385+
386+
Py_ssize_t pos = (char*)buf - (char*)PyBytesWriter_GetData(writer);
387+
if (PyBytesWriter_Grow(writer, size) < 0) {
388+
return NULL;
389+
}
390+
return (char*)PyBytesWriter_GetData(writer) + pos;

Doc/c-api/init.rst

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ The following functions can be safely called before Python is initialized:
4141
* :c:func:`PyObject_SetArenaAllocator`
4242
* :c:func:`Py_SetProgramName`
4343
* :c:func:`Py_SetPythonHome`
44-
* :c:func:`PySys_ResetWarnOptions`
4544
* the configuration functions covered in :ref:`init-config`
4645

4746
* Informative functions:
@@ -1020,6 +1019,12 @@ code, or when embedding the Python interpreter:
10201019
interpreter lock is also shared by all threads, regardless of to which
10211020
interpreter they belong.
10221021
1022+
.. versionchanged:: 3.12
1023+
1024+
:pep:`684` introduced the possibility
1025+
of a :ref:`per-interpreter GIL <per-interpreter-gil>`.
1026+
See :c:func:`Py_NewInterpreterFromConfig`.
1027+
10231028
10241029
.. c:type:: PyThreadState
10251030
@@ -1711,6 +1716,8 @@ function. You can create and destroy them using the following functions:
17111716
haven't been explicitly destroyed at that point.
17121717
17131718
1719+
.. _per-interpreter-gil:
1720+
17141721
A Per-Interpreter GIL
17151722
---------------------
17161723
@@ -1722,7 +1729,7 @@ being blocked by other interpreters or blocking any others. Thus a
17221729
single Python process can truly take advantage of multiple CPU cores
17231730
when running Python code. The isolation also encourages a different
17241731
approach to concurrency than that of just using threads.
1725-
(See :pep:`554`.)
1732+
(See :pep:`554` and :pep:`684`.)
17261733
17271734
Using an isolated interpreter requires vigilance in preserving that
17281735
isolation. That especially means not sharing any objects or mutable
@@ -2003,6 +2010,11 @@ Reference tracing
20032010
is set to :c:data:`PyRefTracer_DESTROY`). The **data** argument is the opaque pointer
20042011
that was provided when :c:func:`PyRefTracer_SetTracer` was called.
20052012
2013+
If a new tracing function is registered replacing the current a call to the
2014+
trace function will be made with the object set to **NULL** and **event** set to
2015+
:c:data:`PyRefTracer_TRACKER_REMOVED`. This will happen just before the new
2016+
function is registered.
2017+
20062018
.. versionadded:: 3.13
20072019
20082020
.. c:var:: int PyRefTracer_CREATE
@@ -2015,6 +2027,13 @@ Reference tracing
20152027
The value for the *event* parameter to :c:type:`PyRefTracer` functions when a Python
20162028
object has been destroyed.
20172029
2030+
.. c:var:: int PyRefTracer_TRACKER_REMOVED
2031+
2032+
The value for the *event* parameter to :c:type:`PyRefTracer` functions when the
2033+
current tracer is about to be replaced by a new one.
2034+
2035+
.. versionadded:: 3.14
2036+
20182037
.. c:function:: int PyRefTracer_SetTracer(PyRefTracer tracer, void *data)
20192038
20202039
Register a reference tracer function. The function will be called when a new
@@ -2030,6 +2049,10 @@ Reference tracing
20302049
20312050
There must be an :term:`attached thread state` when calling this function.
20322051
2052+
If another tracer function was already registered, the old function will be
2053+
called with **event** set to :c:data:`PyRefTracer_TRACKER_REMOVED` just before
2054+
the new function is registered.
2055+
20332056
.. versionadded:: 3.13
20342057
20352058
.. c:function:: PyRefTracer PyRefTracer_GetTracer(void** data)

0 commit comments

Comments
 (0)