Skip to content

Commit fd151bd

Browse files
Merge remote-tracking branch 'upstream/main' into csv-writer-special-bitmap
2 parents 38e579c + fde6296 commit fd151bd

371 files changed

Lines changed: 10165 additions & 3125 deletions

File tree

Some content is hidden

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

.claude/CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../AGENTS.md

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ Lib/test/test_unittest/testmock/ @cjw296
630630
Doc/library/zlib.rst @StanFromIreland
631631
Lib/compression/zlib.py @StanFromIreland
632632
Lib/test/test_zlib.py @StanFromIreland
633-
Modules/_zlibmodule.c @StanFromIreland
633+
Modules/zlibmodule.c @StanFromIreland
634634

635635
# Zipfile.Path
636636
Lib/test/test_zipfile/_path/ @jaraco

.github/workflows/reusable-docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ jobs:
8686
--fail-if-regression \
8787
--fail-if-improved \
8888
--fail-if-new-news-nit
89+
- name: 'Build list of changes'
90+
run: |
91+
make -C Doc/ PYTHON=../python changes
8992
- name: 'Collect HTML IDs'
9093
if: github.event_name == 'pull_request'
9194
run: python Doc/tools/check-html-ids.py collect Doc/build/html -o Doc/build/html-ids-head.json.gz

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,12 @@ Python/frozen_modules/MANIFEST
178178
/python
179179
!/Python/
180180

181-
# People's custom https://docs.anthropic.com/en/docs/claude-code/memory configs.
182-
/.claude/
181+
# Local AI agent scratch state (per-PR and per-branch notebooks, sandbox
182+
# experiments) and personal agent overrides, none of which are committed.
183+
/.claude/pr-*
184+
/.claude/branch-*
185+
/.claude/sandbox/
186+
AGENTS.local.md
183187
CLAUDE.local.md
184188

185189
#### main branch only stuff below this line, things to backport go above. ####

AGENTS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# AI agent guidance
2+
3+
CPython has a [policy on the use of AI tools](https://devguide.python.org/getting-started/ai-tools/).
4+
All use of AI tools and agents when working on or interacting with CPython
5+
must follow it.
6+
7+
> [!important]
8+
> **Primary directive**: Read the policy before making or proposing any changes.
9+
10+
When acting on this repository, apply the policy's core principles:
11+
12+
- Consider whether the change is necessary.
13+
- Make minimal, focused changes.
14+
- Follow existing coding style and patterns.
15+
- Write tests that exercise the change.
16+
- Keep backwards compatibility with prior releases in mind.

Doc/c-api/bytes.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ called with a non-bytes parameter.
231231
Resize a bytes object. *newsize* will be the new length of the bytes object.
232232
You can think of it as creating a new bytes object and destroying the old
233233
one, only more efficiently.
234+
234235
Pass the address of an
235236
existing bytes object as an lvalue (it may be written into), and the new size
236237
desired. On success, *\*bytes* holds the resized bytes object and ``0`` is
@@ -239,6 +240,11 @@ called with a non-bytes parameter.
239240
*\*bytes* is set to ``NULL``, :exc:`MemoryError` is set, and ``-1`` is
240241
returned.
241242
243+
While bytes objects are usually immutable in Python, this special C API
244+
allows mutating a bytes object in-place. The returned bytes object can still
245+
be mutated using :c:func:`PyBytesWriter_GetData`; except if *newsize* is
246+
zero in which case it returns the immutable empty bytes string.
247+
242248
.. soft-deprecated:: 3.15
243249
Use the :c:type:`PyBytesWriter` API instead.
244250
@@ -290,10 +296,10 @@ object.
290296
291297
.. c:type:: PyBytesWriter
292298
293-
A bytes writer instance.
299+
A bytes writer object.
294300
295-
The API is **not thread safe**: a writer should only be used by a single
296-
thread at the same time.
301+
The API is **not thread safe**. A :c:type:`PyBytesWriter` object must only
302+
be used by a single thread, it must not be shared between threads.
297303
298304
The instance must be destroyed by :c:func:`PyBytesWriter_Finish` on
299305
success, or :c:func:`PyBytesWriter_Discard` on error.
@@ -429,7 +435,7 @@ Low-level API
429435
On success, return ``0``.
430436
On error, set an exception and return ``-1``.
431437
432-
*size* can be negative to shrink the writer.
438+
*grow* can be negative to shrink the writer.
433439
434440
.. c:function:: void* PyBytesWriter_GrowAndUpdatePointer(PyBytesWriter *writer, Py_ssize_t size, void *buf)
435441

Doc/c-api/complex.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,6 @@ the :ref:`Number Protocol <number>` API or use native complex types, like
197197
Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows.
198198
199199
.. deprecated:: 3.15
200+
201+
.. versionchanged:: next
202+
This function leaves :c:data:`errno` unchanged on success.

Doc/c-api/marshal.rst

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ Numeric values are stored with the least significant byte first.
1616
The module supports several versions of the data format; see
1717
the :py:mod:`Python module documentation <marshal>` for details.
1818

19+
The following exceptions can be raised by these functions:
20+
:exc:`ValueError` if the value cannot be marshalled,
21+
:exc:`ValueError` or :exc:`TypeError` if the data is malformed,
22+
:exc:`EOFError` if the end of the data is reached before the value is complete,
23+
:exc:`OSError` if reading from or writing to a :c:expr:`FILE*` fails,
24+
:exc:`KeyboardInterrupt` if reading or writing is interrupted by a signal,
25+
and :exc:`MemoryError` if memory allocation fails.
26+
27+
.. versionchanged:: next
28+
Previously, in functions taking a :c:expr:`FILE*`,
29+
the reading functions raised :exc:`EOFError`
30+
instead of :exc:`OSError` and :exc:`KeyboardInterrupt`,
31+
and the writing functions ignored I/O errors and interruptions.
32+
1933
.. c:macro:: Py_MARSHAL_VERSION
2034
2135
The current format version. See :py:data:`marshal.version`.
@@ -42,6 +56,8 @@ the :py:mod:`Python module documentation <marshal>` for details.
4256
Return a bytes object containing the marshalled representation of *value*.
4357
*version* indicates the file format.
4458
59+
On error, raises an exception and returns ``NULL``.
60+
4561
4662
The following functions allow marshalled values to be read back in.
4763
@@ -52,8 +68,7 @@ The following functions allow marshalled values to be read back in.
5268
for reading. Only a 32-bit value can be read in using this function,
5369
regardless of the native size of :c:expr:`long`.
5470
55-
On error, sets the appropriate exception (:exc:`EOFError`) and returns
56-
``-1``.
71+
On error, raises an exception and returns ``-1``.
5772
5873
5974
.. c:function:: int PyMarshal_ReadShortFromFile(FILE *file)
@@ -62,17 +77,15 @@ The following functions allow marshalled values to be read back in.
6277
for reading. Only a 16-bit value can be read in using this function,
6378
regardless of the native size of :c:expr:`short`.
6479
65-
On error, sets the appropriate exception (:exc:`EOFError`) and returns
66-
``-1``.
80+
On error, raises an exception and returns ``-1``.
6781
6882
6983
.. c:function:: PyObject* PyMarshal_ReadObjectFromFile(FILE *file)
7084
7185
Return a Python object from the data stream in a :c:expr:`FILE*` opened for
7286
reading.
7387
74-
On error, sets the appropriate exception (:exc:`EOFError`, :exc:`ValueError`
75-
or :exc:`TypeError`) and returns ``NULL``.
88+
On error, raises an exception and returns ``NULL``.
7689
7790
7891
.. c:function:: PyObject* PyMarshal_ReadLastObjectFromFile(FILE *file)
@@ -85,15 +98,13 @@ The following functions allow marshalled values to be read back in.
8598
file. Only use this variant if you are certain that you won't be reading
8699
anything else from the file.
87100
88-
On error, sets the appropriate exception (:exc:`EOFError`, :exc:`ValueError`
89-
or :exc:`TypeError`) and returns ``NULL``.
101+
On error, raises an exception and returns ``NULL``.
90102
91103
92104
.. c:function:: PyObject* PyMarshal_ReadObjectFromString(const char *data, Py_ssize_t len)
93105
94106
Return a Python object from the data stream in a byte buffer
95107
containing *len* bytes pointed to by *data*.
96108
97-
On error, sets the appropriate exception (:exc:`EOFError`, :exc:`ValueError`
98-
or :exc:`TypeError`) and returns ``NULL``.
109+
On error, raises an exception and returns ``NULL``.
99110

Doc/c-api/module.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ struct:
853853
854854
.. versionadded:: 3.5
855855
856-
.. soft-deprecated:: next
856+
.. soft-deprecated:: 3.15
857857
858858
Prefer :c:func:`PyModule_FromSlotsAndSpec` in new code.
859859
@@ -877,7 +877,7 @@ struct:
877877
878878
.. versionadded:: 3.5
879879
880-
.. soft-deprecated:: next
880+
.. soft-deprecated:: 3.15
881881
882882
Prefer :c:func:`PyModule_FromSlotsAndSpec` in new code.
883883
@@ -887,7 +887,7 @@ struct:
887887
888888
.. versionadded:: 3.5
889889
890-
.. soft-deprecated:: next
890+
.. soft-deprecated:: 3.15
891891
892892
To run a module's own execution slots, prefer :c:func:`PyModule_Exec`,
893893
which works on modules that were not created from a

Doc/c-api/type.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ They will continue to work, but new features will be added as slots for
828828
829829
.. versionadded:: 3.12
830830
831-
.. soft-deprecated:: next
831+
.. soft-deprecated:: 3.15
832832
833833
Prefer :c:func:`PyType_FromSlots` in new code.
834834
@@ -859,7 +859,7 @@ They will continue to work, but new features will be added as slots for
859859
Creating classes whose metaclass overrides
860860
:c:member:`~PyTypeObject.tp_new` is no longer allowed.
861861
862-
.. soft-deprecated:: next
862+
.. soft-deprecated:: 3.15
863863
864864
Prefer :c:func:`PyType_FromSlots` in new code.
865865
@@ -885,7 +885,7 @@ They will continue to work, but new features will be added as slots for
885885
Creating classes whose metaclass overrides
886886
:c:member:`~PyTypeObject.tp_new` is no longer allowed.
887887
888-
.. soft-deprecated:: next
888+
.. soft-deprecated:: 3.15
889889
890890
Prefer :c:func:`PyType_FromSlots` in new code.
891891
@@ -910,7 +910,7 @@ They will continue to work, but new features will be added as slots for
910910
Creating classes whose metaclass overrides
911911
:c:member:`~PyTypeObject.tp_new` is no longer allowed.
912912
913-
.. soft-deprecated:: next
913+
.. soft-deprecated:: 3.15
914914
915915
Prefer :c:func:`PyType_FromSlots` in new code.
916916

0 commit comments

Comments
 (0)