Skip to content

Commit 2dffa77

Browse files
authored
Merge branch 'main' into improve-datetime-docstrings
2 parents 7094699 + f01181b commit 2dffa77

File tree

255 files changed

+29112
-23269
lines changed

Some content is hidden

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

255 files changed

+29112
-23269
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/Setup* @erlend-aasland @AA-Turner @emmatyping
86+
Modules/makesetup @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

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

Doc/c-api/init_config.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,11 @@ PyConfig
12781278
12791279
Default: ``0``.
12801280
1281+
.. deprecated-removed:: 3.15 3.17
1282+
1283+
The :option:`-b` and :option:`!-bb` options will become no-op in 3.17.
1284+
:c:member:`~PyConfig.bytes_warning` member will be removed in 3.17.
1285+
12811286
.. c:member:: int warn_default_encoding
12821287
12831288
If non-zero, emit a :exc:`EncodingWarning` warning when :class:`io.TextIOWrapper`

0 commit comments

Comments
 (0)