Skip to content

Commit 9b29c7c

Browse files
generatedunixname1734921407115435meta-codesync[bot]
authored andcommitted
Import CPython 3.14.6+ stable branch (2026-07-21)
Summary: Imported python/cpython `3.14.6+` from upstream rev [`856c811`](https://www.github.com/python/cpython/commit/856c8119ea9d8f574dd56cf64afe19ee2e460c8b) (committed 2026-07-21 03:54:27+00:00). # Commit Info - Base: (`3.14.6+`) - [`9bd5e97`](https://www.github.com/python/cpython/commit/9bd5e97b7521aef5f568c70d6b4c9436e29a3e97) (commit date: 2026-07-17 22:36:17+00:00) - Imported: (`3.14.6+`) - [`856c811`](https://www.github.com/python/cpython/commit/856c8119ea9d8f574dd56cf64afe19ee2e460c8b) (commit date: 2026-07-21 03:54:27+00:00) # Noteworthy file changes - Low-signal files (20 added) (NEWS.d, docs, .github) Complete list of added/removed files: https://www.internalfb.com/intern/everpaste/?color=0&handle=GOgOOx4d3p-u6wwDAB2V_3PPgCobbr0LAAAz Reviewed By: itamaro Differential Revision: D113001771 fbshipit-source-id: abdd0769873a5caddff297d94cd516b6bcf3f4fc
1 parent 060484b commit 9b29c7c

101 files changed

Lines changed: 979 additions & 198 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/perfmaps.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,43 @@ Note that holding an :term:`attached thread state` is not required for these API
4848
This is called by the runtime itself during interpreter shut-down. In
4949
general, there shouldn't be a reason to explicitly call this, except to
5050
handle specific scenarios such as forking.
51+
52+
.. c:function:: int PyUnstable_CopyPerfMapFile(const char *parent_filename)
53+
54+
Open the ``/tmp/perf-$pid.map`` file and append the content of *parent_filename*
55+
to it.
56+
57+
This function is available on all platforms but only generates output on platforms
58+
that support perf maps (currently only Linux). On other platforms, it does nothing.
59+
60+
.. versionadded:: 3.13
61+
62+
.. c:function:: int PyUnstable_PerfTrampoline_CompileCode(PyCodeObject *code)
63+
64+
Compile the given code object using the current perf trampoline.
65+
66+
The "current" trampoline is the one set by the runtime or the most recent
67+
:c:func:`PyUnstable_PerfTrampoline_SetPersistAfterFork` call.
68+
69+
If no trampoline is set, falls back to normal compilation (no perf map entry).
70+
71+
:param code: The code object to compile.
72+
:return: 0 on success, -1 on failure.
73+
74+
.. versionadded:: 3.13
75+
76+
.. c:function:: int PyUnstable_PerfTrampoline_SetPersistAfterFork(int enable)
77+
78+
Set whether the perf trampoline should persist after a fork.
79+
80+
* If ``enable`` is true (non-zero): perf map file remains open/valid post-fork.
81+
Child process inherits all existing perf map entries.
82+
* If ``enable`` is false (zero): perf map closes post-fork.
83+
Child process gets empty perf map.
84+
85+
Default: false (clears on fork).
86+
87+
:param enable: 1 to enable, 0 to disable.
88+
:return: 0 on success, -1 on failure.
89+
90+
.. versionadded:: 3.13

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3128,7 +3128,7 @@ Buffer Object Structures
31283128

31293129
* Resource cleanup when the counter reaches zero must be done atomically,
31303130
as the final release may race with concurrent releases from other
3131-
threads and dellocation must only happen once.
3131+
threads and deallocation must only happen once.
31323132

31333133
The exporter MUST use the :c:member:`~Py_buffer.internal` field to keep
31343134
track of buffer-specific resources. This field is guaranteed to remain

Doc/c-api/veryhigh.rst

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,93 @@ 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
.. c:macro:: PyCF_DISABLE_LAZY_IMPORTS
347434
348435
Compile the code with :ref:`lazy imports <lazy-imports>` disabled, so that
@@ -355,6 +442,33 @@ the same library that the Python runtime is using.
355442
selectable using :ref:`future statements <future>`.
356443
See :ref:`c_codeobject_flags` for a complete list.
357444
445+
The following masks combine several flags:
446+
447+
.. c:macro:: PyCF_MASK
448+
449+
Bitmask of all ``CO_FUTURE`` flags (see :ref:`c_codeobject_flags`),
450+
which select features normally enabled by
451+
:ref:`future statements <future>`.
452+
When code compiled with a ``PyCompilerFlags *flags`` argument
453+
contains a ``from __future__ import`` statement, the flag for the
454+
imported feature is added to *flags*, so that code executed later
455+
in the same context inherits it.
456+
457+
.. c:macro:: PyCF_MASK_OBSOLETE
458+
459+
Do not use this mask in new code. It is kept only so that old
460+
code passing its flags to :func:`compile` keeps working.
461+
462+
Bitmask of flags for obsolete future features that no longer
463+
have any effect.
464+
465+
.. c:macro:: PyCF_COMPILE_MASK
466+
467+
Bitmask of all ``PyCF`` flags that change how the source is
468+
compiled, such as :c:macro:`PyCF_ONLY_AST`.
469+
The :func:`compile` built-in function uses this mask to validate
470+
its *flags* argument.
471+
358472
359473
.. _start-symbols:
360474

Doc/howto/logging-cookbook.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,7 @@ Subclass ``QueueListener``
19601960
class NNGSocketListener(logging.handlers.QueueListener):
19611961
19621962
def __init__(self, uri, /, *handlers, **kwargs):
1963-
# Have a timeout for interruptability, and open a
1963+
# Have a timeout for interruptibility, and open a
19641964
# subscriber socket
19651965
socket = pynng.Sub0(listen=uri, recv_timeout=500)
19661966
# The b'' subscription matches all topics

Doc/library/ast.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ Control flow
13641364

13651365
``try`` blocks which are followed by ``except*`` clauses. The attributes are the
13661366
same as for :class:`Try` but the :class:`ExceptHandler` nodes in ``handlers``
1367-
are interpreted as ``except*`` blocks rather then ``except``.
1367+
are interpreted as ``except*`` blocks rather than ``except``.
13681368

13691369
.. doctest::
13701370

Doc/library/calendar.rst

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

399399

400-
.. function:: weekheader(n)
400+
.. function:: weekheader(width)
401401

402-
Return a header containing abbreviated weekday names. *n* specifies the width in
402+
Return a header containing abbreviated weekday names. *width* specifies the width in
403403
characters for one weekday.
404404

405405

@@ -427,12 +427,12 @@ For simple text calendars this module provides the following functions.
427427
of the :class:`TextCalendar` class.
428428

429429

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

432432
Prints the calendar for an entire year as returned by :func:`calendar`.
433433

434434

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

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

Doc/library/compression.zstd.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ Advanced parameter control
499499
The :meth:`~.bounds` method can be used on any attribute to get the valid
500500
values for that parameter.
501501

502-
Parameters are optional; any omitted parameter will have it's value selected
502+
Parameters are optional; any omitted parameter will have its value selected
503503
automatically.
504504

505505
Example getting the lower and upper bound of :attr:`~.compression_level`::
@@ -728,7 +728,7 @@ Advanced parameter control
728728

729729
An :class:`~enum.IntEnum` containing the advanced decompression parameter
730730
keys that can be used when decompressing data. Parameters are optional; any
731-
omitted parameter will have it's value selected automatically.
731+
omitted parameter will have its value selected automatically.
732732

733733
The :meth:`~.bounds` method can be used on any attribute to get the valid
734734
values for that parameter.

Doc/library/concurrent.interpreters.rst

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

2929
.. seealso::
3030

0 commit comments

Comments
 (0)