Skip to content

Commit ed78614

Browse files
authored
Merge branch 'main' into fix-json-tool
2 parents 2d5e1bf + d873fb4 commit ed78614

File tree

247 files changed

+6721
-2703
lines changed

Some content is hidden

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

247 files changed

+6721
-2703
lines changed

.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

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: 16 additions & 1 deletion
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:
@@ -2011,6 +2010,11 @@ Reference tracing
20112010
is set to :c:data:`PyRefTracer_DESTROY`). The **data** argument is the opaque pointer
20122011
that was provided when :c:func:`PyRefTracer_SetTracer` was called.
20132012
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+
20142018
.. versionadded:: 3.13
20152019
20162020
.. c:var:: int PyRefTracer_CREATE
@@ -2023,6 +2027,13 @@ Reference tracing
20232027
The value for the *event* parameter to :c:type:`PyRefTracer` functions when a Python
20242028
object has been destroyed.
20252029
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+
20262037
.. c:function:: int PyRefTracer_SetTracer(PyRefTracer tracer, void *data)
20272038
20282039
Register a reference tracer function. The function will be called when a new
@@ -2038,6 +2049,10 @@ Reference tracing
20382049
20392050
There must be an :term:`attached thread state` when calling this function.
20402051
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+
20412056
.. versionadded:: 3.13
20422057
20432058
.. 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`

Doc/c-api/sys.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,6 @@ accessible to C code. They all work with the current interpreter thread's
316316
case *name* is deleted from the sys module. Returns ``0`` on success, ``-1``
317317
on error.
318318
319-
.. c:function:: void PySys_ResetWarnOptions()
320-
321-
Reset :data:`sys.warnoptions` to an empty list. This function may be
322-
called prior to :c:func:`Py_Initialize`.
323-
324-
.. deprecated-removed:: 3.13 3.15
325-
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
326-
327319
.. c:function:: void PySys_WriteStdout(const char *format, ...)
328320
329321
Write the output string described by *format* to :data:`sys.stdout`. No

Doc/c-api/veryhigh.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ the same library that the Python runtime is using.
183183
objects *globals* and *locals* with the compiler flags specified by
184184
*flags*. *globals* must be a dictionary; *locals* can be any object
185185
that implements the mapping protocol. The parameter *start* specifies
186-
the start token that should be used to parse the source code.
186+
the start symbol and must one of the following:
187+
:c:data:`Py_eval_input`, :c:data:`Py_file_input`, or :c:data:`Py_single_input`.
187188
188189
Returns the result of executing the code as a Python object, or ``NULL`` if an
189190
exception was raised.
@@ -231,7 +232,7 @@ the same library that the Python runtime is using.
231232
.. c:function:: PyObject* Py_CompileStringObject(const char *str, PyObject *filename, int start, PyCompilerFlags *flags, int optimize)
232233
233234
Parse and compile the Python source code in *str*, returning the resulting code
234-
object. The start token is given by *start*; this can be used to constrain the
235+
object. The start symbol is given by *start*; this can be used to constrain the
235236
code which can be compiled and should be :c:data:`Py_eval_input`,
236237
:c:data:`Py_file_input`, or :c:data:`Py_single_input`. The filename specified by
237238
*filename* is used to construct the code object and may appear in tracebacks or

Doc/data/stable_abi.dat

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/deprecations/c-api-pending-removal-in-3.15.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Pending removal in Python 3.15
5959
Set :c:member:`PyConfig.program_name` instead.
6060
* :c:func:`!Py_SetPythonHome()`:
6161
Set :c:member:`PyConfig.home` instead.
62-
* :c:func:`PySys_ResetWarnOptions`:
62+
* :c:func:`!PySys_ResetWarnOptions`:
6363
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
6464

6565
The :c:func:`Py_InitializeFromConfig` API should be used with

Doc/deprecations/c-api-pending-removal-in-3.18.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
Pending removal in Python 3.18
22
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33

4-
* Deprecated private functions (:gh:`128863`):
4+
* The following private functions are deprecated
5+
and planned for removal in Python 3.18:
56

67
* :c:func:`!_PyBytes_Join`: use :c:func:`PyBytes_Join`.
78
* :c:func:`!_PyDict_GetItemStringWithError`: use :c:func:`PyDict_GetItemStringRef`.
8-
* :c:func:`!_PyDict_Pop()`: :c:func:`PyDict_Pop`.
9+
* :c:func:`!_PyDict_Pop()`: use :c:func:`PyDict_Pop`.
910
* :c:func:`!_PyLong_Sign()`: use :c:func:`PyLong_GetSign`.
1011
* :c:func:`!_PyLong_FromDigits` and :c:func:`!_PyLong_New`:
1112
use :c:func:`PyLongWriter_Create`.
@@ -31,7 +32,7 @@ Pending removal in Python 3.18
3132
:c:func:`PyUnicodeWriter_WriteSubstring(writer, str, start, end) <PyUnicodeWriter_WriteSubstring>`.
3233
* :c:func:`!_PyUnicodeWriter_WriteASCIIString`:
3334
replace ``_PyUnicodeWriter_WriteASCIIString(&writer, str)`` with
34-
:c:func:`PyUnicodeWriter_WriteUTF8(writer, str) <PyUnicodeWriter_WriteUTF8>`.
35+
:c:func:`PyUnicodeWriter_WriteASCII(writer, str) <PyUnicodeWriter_WriteASCII>`.
3536
* :c:func:`!_PyUnicodeWriter_WriteLatin1String`:
3637
replace ``_PyUnicodeWriter_WriteLatin1String(&writer, str)`` with
3738
:c:func:`PyUnicodeWriter_WriteUTF8(writer, str) <PyUnicodeWriter_WriteUTF8>`.
@@ -41,5 +42,6 @@ Pending removal in Python 3.18
4142
* :c:func:`!_Py_fopen_obj`: use :c:func:`Py_fopen`.
4243

4344
The `pythoncapi-compat project
44-
<https://github.com/python/pythoncapi-compat/>`__ can be used to get these
45-
new public functions on Python 3.13 and older.
45+
<https://github.com/python/pythoncapi-compat/>`__ can be used to get
46+
these new public functions on Python 3.13 and older.
47+
(Contributed by Victor Stinner in :gh:`128863`.)

Doc/deprecations/pending-removal-in-3.14.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ Pending removal in Python 3.14
3838
is no current event loop set and it decides to create one.
3939
(Contributed by Serhiy Storchaka and Guido van Rossum in :gh:`100160`.)
4040

41-
* :mod:`collections.abc`: Deprecated :class:`!collections.abc.ByteString`.
42-
Prefer :class:`!Sequence` or :class:`~collections.abc.Buffer`.
43-
For use in typing, prefer a union, like ``bytes | bytearray``,
44-
or :class:`collections.abc.Buffer`.
45-
(Contributed by Shantanu Jain in :gh:`91896`.)
46-
4741
* :mod:`email`: Deprecated the *isdst* parameter in :func:`email.utils.localtime`.
4842
(Contributed by Alan Williams in :gh:`72346`.)
4943

@@ -96,9 +90,6 @@ Pending removal in Python 3.14
9690
if :ref:`named placeholders <sqlite3-placeholders>` are used and
9791
*parameters* is a sequence instead of a :class:`dict`.
9892

99-
* :mod:`typing`: :class:`!typing.ByteString`, deprecated since Python 3.9,
100-
now causes a :exc:`DeprecationWarning` to be emitted when it is used.
101-
10293
* :mod:`urllib`:
10394
:class:`!urllib.parse.Quoter` is deprecated: it was not intended to be a
10495
public API.

0 commit comments

Comments
 (0)