Skip to content

Commit c4ec95e

Browse files
authored
Merge branch 'main' into jit-on-rosetta
2 parents bd506f4 + 1ebd726 commit c4ec95e

File tree

558 files changed

+38446
-27701
lines changed

Some content is hidden

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

558 files changed

+38446
-27701
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: 17 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
@@ -405,11 +406,15 @@ Lib/test/test_dataclasses/ @ericvsmith
405406

406407
# Dates and times
407408
Doc/**/*time.rst @pganssle @abalkin
409+
Doc/library/zoneinfo.rst @pganssle
408410
Include/datetime.h @pganssle @abalkin
409411
Include/internal/pycore_time.h @pganssle @abalkin
412+
Lib/test/test_zoneinfo/ @pganssle
413+
Lib/zoneinfo/ @pganssle
410414
Lib/*time.py @pganssle @abalkin
411415
Lib/test/datetimetester.py @pganssle @abalkin
412416
Lib/test/test_*time.py @pganssle @abalkin
417+
Modules/*zoneinfo* @pganssle
413418
Modules/*time* @pganssle @abalkin
414419
Python/pytime.c @pganssle @abalkin
415420

@@ -603,9 +608,9 @@ Lib/test/test_zipfile/_path/ @jaraco
603608
Lib/zipfile/_path/ @jaraco
604609

605610
# Zstandard
606-
Lib/compression/zstd/ @AA-Turner
607-
Lib/test/test_zstd.py @AA-Turner
608-
Modules/_zstd/ @AA-Turner
611+
Lib/compression/zstd/ @AA-Turner @emmatyping
612+
Lib/test/test_zstd.py @AA-Turner @emmatyping
613+
Modules/_zstd/ @AA-Turner @emmatyping
609614

610615
# ----------------------------------------------------------------------------
611616

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

.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;

0 commit comments

Comments
 (0)