Skip to content

Commit f4ed052

Browse files
committed
Merge branch 'main' into atan2
2 parents d546e81 + e757c06 commit f4ed052

294 files changed

Lines changed: 8298 additions & 1997 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

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

Doc/howto/curses.rst

Lines changed: 58 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,21 @@ underline, reverse code, or in color. They'll be explained in more detail in
295295
the next subsection.
296296

297297

298-
The :meth:`~curses.window.addstr` method takes a Python string or
299-
bytestring as the value to be displayed. The contents of bytestrings
300-
are sent to the terminal as-is. Strings are encoded to bytes using
301-
the value of the window's :attr:`~window.encoding` attribute; this defaults to
302-
the default system encoding as returned by :func:`locale.getencoding`.
298+
The :meth:`~curses.window.addstr` method takes a Python string, bytestring
299+
or :class:`~curses.complexstr` as the value to be displayed. The contents
300+
of bytestrings are sent to the terminal as-is.
301+
On a build without wide-character support strings are encoded
302+
using the value of the window's :attr:`~window.encoding` attribute;
303+
this defaults to the default system encoding
304+
as returned by :func:`locale.getencoding`.
303305

304306
The :meth:`~curses.window.addch` methods take a character, which can be
305-
either a string of length 1, a bytestring of length 1, or an integer.
307+
either a string of length 1, a bytestring of length 1, an integer, or a
308+
:class:`~curses.complexchar`.
306309

307-
Constants are provided for extension characters; these constants are
308-
integers greater than 255. For example, :const:`ACS_PLMINUS` is a +/-
310+
Constants are provided for the characters of the terminal's alternate
311+
character set.
312+
For example, :const:`ACS_PLMINUS` is a +/-
309313
symbol, and :const:`ACS_ULCORNER` is the upper left corner of a box
310314
(handy for drawing borders). You can also use the appropriate Unicode
311315
character.
@@ -319,11 +323,11 @@ won't be distracting; it can be confusing to have the cursor blinking at some
319323
apparently random location.
320324

321325
If your application doesn't need a blinking cursor at all, you can
322-
call ``curs_set(False)`` to make it invisible. For compatibility
323-
with older curses versions, there's a ``leaveok(bool)`` function
324-
that's a synonym for :func:`~curses.curs_set`. When *bool* is true, the
325-
curses library will attempt to suppress the flashing cursor, and you
326-
won't need to worry about leaving it in odd locations.
326+
call ``curs_set(False)`` to make it invisible.
327+
The window method :meth:`~curses.window.leaveok` does something different:
328+
when its argument is true,
329+
curses leaves the cursor wherever the last update put it,
330+
instead of moving it back to the window's cursor position.
327331

328332

329333
Attributes and Color
@@ -364,6 +368,14 @@ could code::
364368
curses.A_REVERSE)
365369
stdscr.refresh()
366370

371+
A :class:`~curses.complexchar` carries its attributes and color pair
372+
together with the text of one character cell,
373+
and a :class:`~curses.complexstr` is a run of such cells.
374+
They are what :meth:`~curses.window.in_wch` and
375+
:meth:`~curses.window.in_wchstr` return,
376+
so a part of the screen can be read and written back
377+
with its appearance intact.
378+
367379
The curses library also supports color on those terminals that provide it. The
368380
most common such terminal is probably the Linux console, followed by color
369381
xterms.
@@ -429,40 +441,48 @@ The C curses library offers only very simple input mechanisms. Python's
429441
:mod:`curses` module adds a basic text-input widget. (Other libraries
430442
such as :pypi:`Urwid` have more extensive collections of widgets.)
431443

432-
There are two methods for getting input from a window:
444+
There are three methods for getting input from a window:
433445

434-
* :meth:`~curses.window.getch` refreshes the screen and then waits for
446+
* :meth:`~curses.window.get_wch` refreshes the screen and then waits for
435447
the user to hit a key, displaying the key if :func:`~curses.echo` has been
436448
called earlier. You can optionally specify a coordinate to which
437449
the cursor should be moved before pausing.
438450

439-
* :meth:`~curses.window.getkey` does the same thing but converts the
440-
integer to a string. Individual characters are returned as
441-
1-character strings, and special keys such as function keys return
442-
longer strings containing a key name such as ``KEY_UP`` or ``^G``.
451+
* :meth:`~curses.window.getch` does the same thing but returns the code of
452+
the key instead of a character.
453+
With ncurses this is a single byte of the key's encoding in the current
454+
locale, so a character encoded with several bytes takes several calls,
455+
one byte per call.
456+
457+
* :meth:`~curses.window.getkey` does the same as :meth:`!getch` but returns
458+
a string:
459+
an ordinary key as a 1-character string,
460+
and a special key as its name, such as ``KEY_UP``.
443461

444462
It's possible to not wait for the user using the
445463
:meth:`~curses.window.nodelay` window method. After ``nodelay(True)``,
446-
:meth:`!getch` and :meth:`!getkey` for the window become
447-
non-blocking. To signal that no input is ready, :meth:`!getch` returns
448-
``curses.ERR`` (a value of -1) and :meth:`!getkey` raises an exception.
464+
the reads for the window become non-blocking.
465+
To signal that no input is ready,
466+
:meth:`!get_wch` and :meth:`!getkey` raise an exception,
467+
and :meth:`!getch` returns ``-1``.
449468
There's also a :func:`~curses.halfdelay` function, which can be used to (in
450-
effect) set a timer on each :meth:`!getch`; if no input becomes
469+
effect) set a timer on each read; if no input becomes
451470
available within a specified delay (measured in tenths of a second),
452-
curses raises an exception.
471+
the read fails the same way.
453472

454-
The :meth:`!getch` method returns an integer; if it's between 0 and 255, it
455-
represents the ASCII code of the key pressed. Values greater than 255 are
456-
special keys such as Page Up, Home, or the cursor keys. You can compare the
457-
value returned to constants such as :const:`curses.KEY_PPAGE`,
473+
Special keys such as Page Up, Home, or the cursor keys are returned by all
474+
three as one of the :ref:`KEY_* constants <curses-key-constants>`,
475+
all larger than 255.
476+
You can compare the value returned to constants such as
477+
:const:`curses.KEY_PPAGE`,
458478
:const:`curses.KEY_HOME`, or :const:`curses.KEY_LEFT`. The main loop of
459479
your program may look something like this::
460480

461481
while True:
462-
c = stdscr.getch()
463-
if c == ord('p'):
482+
c = stdscr.get_wch()
483+
if c == 'p':
464484
PrintDocument()
465-
elif c == ord('q'):
485+
elif c == 'q':
466486
break # Exit the while loop
467487
elif c == curses.KEY_HOME:
468488
x = y = 0
@@ -474,16 +494,17 @@ conversion functions that take either integer or 1-character-string arguments
474494
and return the same type. For example, :func:`curses.ascii.ctrl` returns the
475495
control character corresponding to its argument.
476496

477-
There's also a method to retrieve an entire string,
478-
:meth:`~curses.window.getstr`. It isn't used very often, because its
497+
There's also a method to retrieve an entire line,
498+
:meth:`~curses.window.get_wstr`. It isn't used very often, because its
479499
functionality is quite limited; the only editing keys available are
480-
the backspace key and the Enter key, which terminates the string. It
481-
can optionally be limited to a fixed number of characters. ::
500+
the erase and kill characters, and the Enter key, which terminates the line.
501+
It can optionally be limited to a fixed number of characters;
502+
:meth:`~curses.window.getstr` returns a bytes object instead. ::
482503

483504
curses.echo() # Enable echoing of characters
484505

485-
# Get a 15-character string, with the cursor on the top line
486-
s = stdscr.getstr(0,0, 15)
506+
# Get a line of at most 15 characters, with the cursor on the top line
507+
s = stdscr.get_wstr(0,0, 15)
487508

488509
The :mod:`curses.textpad` module supplies a text box that supports an
489510
Emacs-like set of keybindings. Various methods of the

Doc/library/argparse.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,9 @@ how the command-line arguments should be handled. The supplied actions are:
835835
>>> parser.parse_args(['-vvv'])
836836
Namespace(verbose=3)
837837

838-
Note, the *default* will be ``None`` unless explicitly set to *0*.
838+
Unless explicitly set, the *default* will be ``None``. If the default
839+
value is a non-zero number, the count starts from that number rather
840+
than from zero.
839841

840842
* ``'help'`` - This prints a complete help message for all the options in the
841843
current parser and then exits. By default a help action is automatically

Doc/library/ast.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2254,7 +2254,7 @@ and classes for traversing abstract syntax trees:
22542254

22552255
In addition, if ``mode`` is ``'func_type'``, the input syntax is
22562256
modified to correspond to :pep:`484` "signature type comments",
2257-
e.g. ``(str, int) -> List[str]``.
2257+
for example ``(str, int) -> List[str]``.
22582258

22592259
Setting ``feature_version`` to a tuple ``(major, minor)`` will result in
22602260
a "best-effort" attempt to parse using that Python version's grammar.

Doc/library/asyncio-task.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ and reliable way to wait for all tasks in the group to finish.
356356
The signature matches that of :func:`asyncio.create_task`.
357357
If the task group is inactive (e.g. not yet entered,
358358
already finished, or in the process of shutting down),
359-
we will close the given ``coro``.
359+
we will close the given ``coro`` and raise :exc:`RuntimeError`.
360360

361361
.. versionchanged:: 3.13
362362

0 commit comments

Comments
 (0)