Skip to content

Commit 8753cf2

Browse files
generatedunixname1734921407115435meta-codesync[bot]
authored andcommitted
Sync pre-release CPython 3.15 branch from GitHub (2026-07-18)
Summary: Imported python/cpython `3.15.0b4+dev` from upstream rev [`13b29a9`](https://www.github.com/python/cpython/commit/13b29a98388505ecc72e30cd97b5c8b15b1ed751) (committed 2026-07-18 22:07:10+00:00). # Commit Info - Base: (`3.15.0b3+dev`) - [`4d74b76`](https://www.github.com/python/cpython/commit/4d74b76ed2534dfe74e085bcc0c86b2212838c6b) (commit date: 2026-07-18 00:01:13+00:00) - Imported: (`3.15.0b4+dev`) - [`13b29a9`](https://www.github.com/python/cpython/commit/13b29a98388505ecc72e30cd97b5c8b15b1ed751) (commit date: 2026-07-18 22:07:10+00:00) # Noteworthy file changes - Test files (2 added) - Low-signal files (4 added, 142 removed) (NEWS.d, docs, .github) Complete list of added/removed files: https://www.internalfb.com/intern/everpaste/?color=0&handle=GMFK0CHK6tqjYboFAFU1dO3q-U8Wbr0LAAAz Differential Revision: D112718830 fbshipit-source-id: 7d8225c157571fc84c5e9d2b7cc77dd93871bc04
1 parent 545ac03 commit 8753cf2

189 files changed

Lines changed: 2701 additions & 599 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.

Doc/c-api/exceptions.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,12 @@ Querying the error indicator
499499
.. c:function:: void PyErr_SetRaisedException(PyObject *exc)
500500
501501
Set *exc* as the exception currently being raised,
502-
clearing the existing exception if one is set.
502+
clearing the existing exception if one is set. If *exc* is ``NULL``,
503+
just clear the existing exception.
503504
504-
.. warning::
505+
*exc* must be a valid exception or ``NULL``.
505506
506-
This call ":term:`steals <steal>`" a reference to *exc*,
507-
which must be a valid exception.
507+
This call ":term:`steals <steal>`" a reference to *exc*.
508508
509509
.. versionadded:: 3.12
510510

Doc/c-api/frame.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,62 @@ Unless using :pep:`523`, you will not need this.
243243
Return the currently executing line number, or -1 if there is no line number.
244244
245245
.. versionadded:: 3.12
246+
247+
248+
.. c:var:: const PyTypeObject *PyUnstable_ExecutableKinds
249+
250+
An array of executable kinds (executor types) for frames, used for internal
251+
debugging and tracing.
252+
253+
Tools like debuggers and profilers can use this to identify the type of execution
254+
context associated with a frame (such as to filter out internal frames).
255+
The entries are indexed by the following constants:
256+
257+
.. list-table::
258+
:header-rows: 1
259+
:widths: auto
260+
261+
* - Constant
262+
- Description
263+
* - .. c:macro:: PyUnstable_EXECUTABLE_KIND_SKIP
264+
- The frame is internal (For example: inlined) and should be skipped by tools.
265+
* - .. c:macro:: PyUnstable_EXECUTABLE_KIND_PY_FUNCTION
266+
- The frame corresponds to a standard Python function.
267+
* - .. c:macro:: PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION
268+
- The frame corresponds to a function defined in native code.
269+
* - .. c:macro:: PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR
270+
- The frame corresponds to a method on a class instance.
271+
272+
However, Python's C API lacks a function to read the executable kind from
273+
a frame. Instead, use this recipe:
274+
275+
.. code-block:: c
276+
277+
int
278+
get_executable_kind(PyFrameObject *frame)
279+
{
280+
_PyInterpreterFrame *f = frame->f_frame;
281+
PyObject *exec = PyStackRef_AsPyObjectBorrow(f->f_executable);
282+
283+
if (PyCode_Check(exec)) {
284+
return PyUnstable_EXECUTABLE_KIND_PY_FUNCTION;
285+
}
286+
if (PyMethod_Check(exec)) {
287+
return PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION;
288+
}
289+
if (Py_IS_TYPE(exec, &PyMethodDescr_Type)) {
290+
return PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR;
291+
}
292+
293+
return PyUnstable_EXECUTABLE_KIND_SKIP;
294+
}
295+
296+
.. versionadded:: 3.13
297+
298+
299+
.. c:macro:: PyUnstable_EXECUTABLE_KINDS
300+
301+
The number of entries in :c:data:`PyUnstable_ExecutableKinds`.
302+
303+
.. versionadded:: 3.13
304+

Doc/c-api/veryhigh.rst

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,125 @@ the same library that the Python runtime is using.
343343
:py:mod:`!ast` Python module, which exports these constants under
344344
the same names.
345345
346+
.. rubric:: Low-level flags
347+
348+
The following flags and masks serve narrow needs of the standard
349+
library and interactive interpreters. Code outside the standard
350+
library rarely has a reason to use them. They are considered
351+
implementation details and may change at any time.
352+
353+
.. c:macro:: PyCF_ALLOW_INCOMPLETE_INPUT
354+
355+
This flag is a private interface between the compiler and the
356+
:mod:`codeop` module. Do not use it; its behavior is unsupported
357+
and may change without warning.
358+
359+
With this flag set, when compilation fails because the source text
360+
ends where more input is expected, for example in the middle of an
361+
indented block or an unterminated string literal, the error raised
362+
is the undocumented ``_IncompleteInputError``, a subclass of
363+
:exc:`SyntaxError`. The :mod:`codeop` module sets this flag,
364+
together with :c:macro:`PyCF_DONT_IMPLY_DEDENT`, to tell input
365+
that is incomplete apart from input with a real syntax error, so
366+
that interactive interpreters know when to prompt for another
367+
line instead of reporting an error.
368+
369+
.. versionadded:: 3.11
370+
371+
.. c:macro:: PyCF_DONT_IMPLY_DEDENT
372+
373+
By default, when compiling with the :c:var:`Py_single_input` start
374+
symbol, reaching the end of the source text implicitly closes any
375+
open indented blocks. With this flag set, open blocks are only
376+
closed if the last line of the source ends with a newline; otherwise,
377+
compilation fails with a :exc:`SyntaxError`:
378+
379+
.. code-block:: c
380+
381+
PyCompilerFlags flags = {
382+
.cf_flags = 0,
383+
.cf_feature_version = PY_MINOR_VERSION,
384+
};
385+
const char *source = "if a:\n pass";
386+
387+
/* The "if" block is closed implicitly;
388+
this returns a code object: */
389+
Py_CompileStringFlags(source, "<input>", Py_single_input, &flags);
390+
391+
/* With the flag, this fails with a SyntaxError,
392+
because the last line does not end with a newline: */
393+
flags.cf_flags = PyCF_DONT_IMPLY_DEDENT;
394+
Py_CompileStringFlags(source, "<input>", Py_single_input, &flags);
395+
396+
The :mod:`codeop` module uses this flag to detect incomplete
397+
interactive input. While the user is still typing inside an
398+
indented block, the source does not yet end with a newline, so it
399+
fails to compile and the user is prompted for another line.
400+
401+
.. c:macro:: PyCF_IGNORE_COOKIE
402+
403+
Read the source text as UTF-8, ignoring its :pep:`263` encoding
404+
declaration ("coding cookie"), if any:
405+
406+
.. code-block:: c
407+
408+
PyCompilerFlags flags = {
409+
.cf_flags = 0,
410+
.cf_feature_version = PY_MINOR_VERSION,
411+
};
412+
const char *source = "# coding: latin-1\ns = '\xe9'\n";
413+
414+
/* The coding cookie is honored: byte 0xE9 is decoded as
415+
Latin-1, and this returns a code object that sets s to "é": */
416+
Py_CompileStringFlags(source, "<input>", Py_file_input, &flags);
417+
418+
/* With the flag, the cookie is ignored and compilation fails
419+
with a SyntaxError, because 0xE9 is not valid UTF-8: */
420+
flags.cf_flags = PyCF_IGNORE_COOKIE;
421+
Py_CompileStringFlags(source, "<input>", Py_file_input, &flags);
422+
423+
The :func:`compile`, :func:`eval` and :func:`exec` built-in functions
424+
set this flag when the source is a :class:`str` object, because they
425+
pass the text to the parser encoded as UTF-8.
426+
427+
.. c:macro:: PyCF_SOURCE_IS_UTF8
428+
429+
Mark the source text as known to be UTF-8 encoded.
430+
The :func:`compile`, :func:`eval` and :func:`exec` built-in functions
431+
set this flag, but it currently has no effect.
432+
346433
The "``PyCF``" flags above can be combined with "``CO_FUTURE``" flags such
347434
as :c:macro:`CO_FUTURE_ANNOTATIONS` to enable features normally
348435
selectable using :ref:`future statements <future>`.
349436
See :ref:`c_codeobject_flags` for a complete list.
350437
438+
The following masks combine several flags:
439+
440+
.. c:macro:: PyCF_MASK
441+
442+
Bitmask of all ``CO_FUTURE`` flags (see :ref:`c_codeobject_flags`),
443+
which select features normally enabled by
444+
:ref:`future statements <future>`.
445+
When code compiled with a ``PyCompilerFlags *flags`` argument
446+
contains a ``from __future__ import`` statement, the flag for the
447+
imported feature is added to *flags*, so that code executed later
448+
in the same context inherits it.
449+
450+
.. c:macro:: PyCF_MASK_OBSOLETE
451+
452+
Do not use this mask in new code. It is kept only so that old
453+
code passing its flags to :func:`compile` keeps working.
454+
455+
Bitmask of flags for obsolete future features that no longer
456+
have any effect.
457+
458+
.. c:macro:: PyCF_COMPILE_MASK
459+
460+
Bitmask of all ``PyCF`` flags that change how the source is
461+
compiled, such as :c:macro:`PyCF_ONLY_AST`.
462+
The :func:`compile` built-in function uses this mask to validate
463+
its *flags* argument.
464+
351465
352466
.. _start-symbols:
353467

Doc/library/asyncio-task.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ and reliable way to wait for all tasks in the group to finish.
377377

378378
* call it from the task group body based on some condition or event
379379
* pass the task group instance to child tasks via :meth:`create_task`, allowing a child
380-
task to conditionally cancel the entire entire group
380+
task to conditionally cancel the entire group
381381
* pass the task group instance or bound :meth:`cancel` method to some other task *before*
382382
opening the task group, allowing remote cancellation
383383

Doc/library/calendar.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,9 @@ For simple text calendars this module provides the following functions.
400400
*month* (``1``--``12``), *day* (``1``--``31``).
401401

402402

403-
.. function:: weekheader(n)
403+
.. function:: weekheader(width)
404404

405-
Return a header containing abbreviated weekday names. *n* specifies the width in
405+
Return a header containing abbreviated weekday names. *width* specifies the width in
406406
characters for one weekday.
407407

408408

@@ -430,12 +430,12 @@ For simple text calendars this module provides the following functions.
430430
of the :class:`TextCalendar` class.
431431

432432

433-
.. function:: prcal(year, w=0, l=0, c=6, m=3)
433+
.. function:: prcal(theyear, w=0, l=0, c=6, m=3)
434434

435435
Prints the calendar for an entire year as returned by :func:`calendar`.
436436

437437

438-
.. function:: calendar(year, w=2, l=1, c=6, m=3)
438+
.. function:: calendar(theyear, w=2, l=1, c=6, m=3)
439439

440440
Returns a 3-column calendar for an entire year as a multi-line string using
441441
the :meth:`~TextCalendar.formatyear` of the :class:`TextCalendar` class.

Doc/library/concurrent.futures.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ in a REPL or a lambda should not be expected to work.
421421
require the *fork* start method for :class:`ProcessPoolExecutor` you must
422422
explicitly pass ``mp_context=multiprocessing.get_context("fork")``.
423423

424-
.. versionchanged:: next
424+
.. versionchanged:: 3.15
425425
Fixed a deadlock (:gh:`115634`) where the executor could hang after
426426
a worker process exited upon reaching its *max_tasks_per_child*
427427
limit while tasks remained queued.

Doc/library/concurrent.interpreters.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ thread) and calling a function in that execution context.
2121
For concurrency, interpreters themselves (and this module) don't
2222
provide much more than isolation, which on its own isn't useful.
2323
Actual concurrency is available separately through
24-
:mod:`threads <threading>` See `below <interp-concurrency_>`_
24+
:mod:`threads <threading>` -- see `below <interp-concurrency_>`_.
2525

2626
.. seealso::
2727

Doc/library/difflib.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
8585
with inter-line and intra-line change highlights. The table can be generated in
8686
either full or contextual difference mode.
8787

88+
.. warning::
89+
90+
The trailing newlines get stripped before the diff, so the result can be
91+
incomplete. See :gh:`71896` for details.
92+
8893
The constructor for this class is:
8994

9095

Doc/library/filecmp.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ The :mod:`!filecmp` module defines the following functions:
3434
file changes. The entire cache may be cleared using :func:`clear_cache`.
3535

3636

37-
.. function:: cmpfiles(dir1, dir2, common, shallow=True)
37+
.. function:: cmpfiles(a, b, common, shallow=True)
3838

39-
Compare the files in the two directories *dir1* and *dir2* whose names are
39+
Compare the files in the two directories *a* and *b* whose names are
4040
given by *common*.
4141

4242
Returns three lists of file names: *match*, *mismatch*,

Doc/library/functions.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,10 @@ are always available. They are listed here in alphabetical order.
611611
untrusted user-supplied input will lead to security vulnerabilities.
612612

613613
The *source* argument is parsed and evaluated as a Python expression
614-
(technically speaking, a condition list) using the *globals* and *locals*
615-
mappings as global and local namespace. If the *globals* dictionary is
616-
present and does not contain a value for the key ``__builtins__``, a
614+
(technically speaking, an :ref:`expression list <exprlists>`)
615+
using the *globals* and *locals* mappings as global and local namespace.
616+
If the *globals* dictionary is present and does not contain a value for the
617+
key ``__builtins__``, a
617618
reference to the dictionary of the built-in module :mod:`builtins` is
618619
inserted under that key before *source* is parsed.
619620
Overriding ``__builtins__`` can be used to restrict or change the available
@@ -633,6 +634,9 @@ are always available. They are listed here in alphabetical order.
633634
>>> eval('x+1')
634635
2
635636

637+
>>> eval("1, 2")
638+
(1, 2)
639+
636640
This function can also be used to execute arbitrary code objects (such as
637641
those created by :func:`compile`). In this case, pass a code object instead
638642
of a string. If the code object has been compiled with ``'exec'`` as the

0 commit comments

Comments
 (0)