Skip to content

Commit 2bffac9

Browse files
authored
Merge branch 'main' into b/pprint-sorted-dicts-doc-update
2 parents 3a090c5 + e3d9bd6 commit 2bffac9

File tree

421 files changed

+38439
-27347
lines changed

Some content is hidden

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

421 files changed

+38439
-27347
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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ Tools/patchcheck/ @AA-Turner
8282
# Autotools
8383
configure* @erlend-aasland @corona10 @AA-Turner @emmatyping
8484
Makefile.pre.in @erlend-aasland @AA-Turner @emmatyping
85+
Modules/makesetup @erlend-aasland @AA-Turner @emmatyping
8586
Modules/Setup* @erlend-aasland @AA-Turner @emmatyping
86-
Modules/makesetup @emmatyping
8787
Tools/build/regen-configure.sh @AA-Turner
8888

8989

@@ -406,11 +406,15 @@ Lib/test/test_dataclasses/ @ericvsmith
406406

407407
# Dates and times
408408
Doc/**/*time.rst @pganssle @abalkin
409+
Doc/library/zoneinfo.rst @pganssle
409410
Include/datetime.h @pganssle @abalkin
410411
Include/internal/pycore_time.h @pganssle @abalkin
412+
Lib/test/test_zoneinfo/ @pganssle
413+
Lib/zoneinfo/ @pganssle
411414
Lib/*time.py @pganssle @abalkin
412415
Lib/test/datetimetester.py @pganssle @abalkin
413416
Lib/test/test_*time.py @pganssle @abalkin
417+
Modules/*zoneinfo* @pganssle
414418
Modules/*time* @pganssle @abalkin
415419
Python/pytime.c @pganssle @abalkin
416420

.github/workflows/jit.yml

Lines changed: 29 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
@@ -134,6 +134,33 @@ jobs:
134134
make all --jobs 4
135135
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
136136
137+
no-opt-jit:
138+
name: JIT without optimizations (Debug)
139+
needs: interpreter
140+
runs-on: ubuntu-24.04
141+
timeout-minutes: 90
142+
strategy:
143+
fail-fast: false
144+
matrix:
145+
llvm:
146+
- 19
147+
steps:
148+
- uses: actions/checkout@v4
149+
with:
150+
persist-credentials: false
151+
- uses: actions/setup-python@v5
152+
with:
153+
python-version: '3.11'
154+
- name: Build with JIT
155+
run: |
156+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
157+
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
158+
./configure --enable-experimental-jit --with-pydebug
159+
make all --jobs 4
160+
- name: Run tests without optimizations
161+
run: |
162+
PYTHON_UOPS_OPTIMIZE=0 ./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
163+
137164
# XXX: GH-133171
138165
# jit-with-disabled-gil:
139166
# name: Free-Threaded (Debug)

.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

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: 29 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
@@ -1827,6 +1834,10 @@ pointer and a void pointer argument.
18271834
called from the main interpreter. Each subinterpreter now has its own
18281835
list of scheduled calls.
18291836
1837+
.. versionchanged:: 3.12
1838+
This function now always schedules *func* to be run in the main
1839+
interpreter.
1840+
18301841
.. _profiling:
18311842
18321843
Profiling and Tracing
@@ -2003,6 +2014,11 @@ Reference tracing
20032014
is set to :c:data:`PyRefTracer_DESTROY`). The **data** argument is the opaque pointer
20042015
that was provided when :c:func:`PyRefTracer_SetTracer` was called.
20052016
2017+
If a new tracing function is registered replacing the current a call to the
2018+
trace function will be made with the object set to **NULL** and **event** set to
2019+
:c:data:`PyRefTracer_TRACKER_REMOVED`. This will happen just before the new
2020+
function is registered.
2021+
20062022
.. versionadded:: 3.13
20072023
20082024
.. c:var:: int PyRefTracer_CREATE
@@ -2015,6 +2031,13 @@ Reference tracing
20152031
The value for the *event* parameter to :c:type:`PyRefTracer` functions when a Python
20162032
object has been destroyed.
20172033
2034+
.. c:var:: int PyRefTracer_TRACKER_REMOVED
2035+
2036+
The value for the *event* parameter to :c:type:`PyRefTracer` functions when the
2037+
current tracer is about to be replaced by a new one.
2038+
2039+
.. versionadded:: 3.14
2040+
20182041
.. c:function:: int PyRefTracer_SetTracer(PyRefTracer tracer, void *data)
20192042
20202043
Register a reference tracer function. The function will be called when a new
@@ -2030,6 +2053,10 @@ Reference tracing
20302053
20312054
There must be an :term:`attached thread state` when calling this function.
20322055
2056+
If another tracer function was already registered, the old function will be
2057+
called with **event** set to :c:data:`PyRefTracer_TRACKER_REMOVED` just before
2058+
the new function is registered.
2059+
20332060
.. versionadded:: 3.13
20342061
20352062
.. c:function:: PyRefTracer PyRefTracer_GetTracer(void** data)

0 commit comments

Comments
 (0)