Skip to content

Commit eab958e

Browse files
Merge branch 'main' into 3.16-plus-dev
2 parents 6ff0802 + e0293b0 commit eab958e

505 files changed

Lines changed: 19009 additions & 6593 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.

.github/workflows/build.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -361,23 +361,14 @@ jobs:
361361
needs: build-context
362362
if: needs.build-context.outputs.run-ios == 'true'
363363
timeout-minutes: 60
364-
runs-on: macos-14
364+
runs-on: macos-26
365365
steps:
366366
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
367367
with:
368368
persist-credentials: false
369369

370-
# GitHub recommends explicitly selecting the desired Xcode version:
371-
# https://github.com/actions/runner-images/issues/12541#issuecomment-3083850140
372-
# This became a necessity as a result of
373-
# https://github.com/actions/runner-images/issues/12541 and
374-
# https://github.com/actions/runner-images/issues/12751.
375-
- name: Select Xcode version
376-
run: |
377-
sudo xcode-select --switch /Applications/Xcode_15.4.app
378-
379370
- name: Build and test
380-
run: python3 Platforms/Apple ci iOS --fast-ci --simulator 'iPhone SE (3rd generation),OS=17.5'
371+
run: python3 Platforms/Apple ci iOS --fast-ci
381372

382373
build-emscripten:
383374
name: 'Emscripten'

.github/workflows/reusable-emscripten.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,5 @@ jobs:
7777
run: python3 Platforms/emscripten pythoninfo-host
7878
- name: "Test"
7979
run: python3 Platforms/emscripten run --test
80+
- name: "Test Repl"
81+
run: Platforms/emscripten/browser_test/run_test.sh

.github/workflows/reusable-san.yml

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ permissions:
1717

1818
env:
1919
FORCE_COLOR: 1
20+
OPENSSL_VER: 3.5.7
2021

2122
jobs:
2223
build-san-reusable:
@@ -38,28 +39,57 @@ jobs:
3839
run: |
3940
sudo ./.github/workflows/posix-deps-apt.sh
4041
# On ubuntu-26.04 image, clang is clang-21 by default
41-
42-
if [ "${SANITIZER}" = "TSan" ]; then
43-
# Reduce ASLR to avoid TSan crashing
44-
sudo sysctl -w vm.mmap_rnd_bits=28
45-
fi
46-
47-
- name: Sanitizer option setup
48-
run: |
49-
if [ "${SANITIZER}" = "TSan" ]; then
50-
echo "TSAN_OPTIONS=${SAN_LOG_OPTION} suppressions=${GITHUB_WORKSPACE}/Tools/tsan/suppressions${{
51-
fromJSON(inputs.free-threading)
52-
&& '_free_threading'
53-
|| ''
54-
}}.txt handle_segv=0" >> "$GITHUB_ENV"
55-
else
56-
echo "UBSAN_OPTIONS=${SAN_LOG_OPTION} halt_on_error=1 suppressions=${GITHUB_WORKSPACE}/Tools/ubsan/suppressions.txt" >> "$GITHUB_ENV"
57-
fi
42+
# NOTE: when bumping to a new version of clang,
43+
# please update the versions in `Tools/pixi-packages/variants.yaml` too.
5844
echo "CC=clang" >> "$GITHUB_ENV"
5945
echo "CXX=clang++" >> "$GITHUB_ENV"
46+
- name: TSan option setup
47+
if: inputs.sanitizer == 'TSan'
48+
run: |
49+
sudo sysctl -w vm.mmap_rnd_bits=28 # Reduce ASLR to avoid TSan crashing
50+
51+
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV"
52+
echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> "$GITHUB_ENV"
53+
echo "TSAN_OPTIONS=${SAN_LOG_OPTION} suppressions=${GITHUB_WORKSPACE}/Tools/tsan/suppressions${SUPPRESSIONS_SUFFIX}.txt handle_segv=0" >> "$GITHUB_ENV"
6054
env:
61-
SANITIZER: ${{ inputs.sanitizer }}
6255
SAN_LOG_OPTION: log_path=${{ github.workspace }}/san_log
56+
SUPPRESSIONS_SUFFIX: >-
57+
${{
58+
fromJSON(inputs.free-threading)
59+
&& '_free_threading'
60+
|| ''
61+
}}
62+
- name: UBSan option setup
63+
if: inputs.sanitizer != 'TSan'
64+
run: >-
65+
echo
66+
"UBSAN_OPTIONS=${SAN_LOG_OPTION}
67+
halt_on_error=1
68+
suppressions=${GITHUB_WORKSPACE}/Tools/ubsan/suppressions.txt"
69+
>> "$GITHUB_ENV"
70+
env:
71+
SAN_LOG_OPTION: log_path=${{ github.workspace }}/san_log
72+
- name: Add ccache to PATH
73+
run: |
74+
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
75+
- name: 'Restore OpenSSL build (TSan)'
76+
id: cache-openssl
77+
if: inputs.sanitizer == 'TSan'
78+
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
79+
with:
80+
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
81+
key: ${{ env.IMAGE_OS_VERSION }}-multissl-openssl-tsan-${{ env.OPENSSL_VER }}
82+
- name: Install OpenSSL (TSan)
83+
if: >-
84+
inputs.sanitizer == 'TSan'
85+
&& steps.cache-openssl.outputs.cache-hit != 'true'
86+
run: >-
87+
python3 Tools/ssl/multissltests.py
88+
--steps=library
89+
--base-directory="${MULTISSL_DIR}"
90+
--openssl="${OPENSSL_VER}"
91+
--system=Linux
92+
--tsan
6393
- name: Configure CPython
6494
run: >-
6595
./configure
@@ -70,6 +100,7 @@ jobs:
70100
|| '--with-undefined-behavior-sanitizer --with-strict-overflow'
71101
}}
72102
--with-pydebug
103+
${{ inputs.sanitizer == 'TSan' && '--with-openssl="$OPENSSL_DIR" --with-openssl-rpath=auto' || '' }}
73104
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
74105
- name: Build CPython
75106
run: make -j4

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,6 @@ most likely :exc:`OverflowError`).
233233
234234
Pack a C double as the IEEE 754 binary64 double precision format.
235235
236-
.. impl-detail::
237-
This function always succeeds in CPython.
238-
239236
240237
Unpack functions
241238
^^^^^^^^^^^^^^^^
@@ -251,9 +248,6 @@ Return value: The unpacked double. On error, this is ``-1.0`` and
251248
:c:func:`PyErr_Occurred` is true (and an exception is set, most likely
252249
:exc:`OverflowError`).
253250
254-
.. impl-detail::
255-
These functions always succeed in CPython.
256-
257251
.. c:function:: double PyFloat_Unpack2(const char *p, int le)
258252
259253
Unpack the IEEE 754 binary16 half-precision format as a C double.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ but need extra remarks for use as slots:
699699
700700
.. soft-deprecated:: 3.15
701701
702-
When not targetting older Python versions, pefer :c:macro:`!Py_tp_bases`.
702+
When not targeting older Python versions, prefer :c:macro:`!Py_tp_bases`.
703703
704704
The following slots do not correspond to public fields in the
705705
underlying structures:

Doc/c-api/typeobj.rst

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

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

30563056
The exporter MUST use the :c:member:`~Py_buffer.internal` field to keep
30573057
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,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/deprecations/pending-removal-in-3.19.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,11 @@ Pending removal in Python 3.19
4040
Before Python 3.14, this property was used to implement the corresponding
4141
``read()`` and ``readline()`` methods for :class:`~imaplib.IMAP4` but this
4242
is no longer the case since then.
43+
44+
* :mod:`tkinter`:
45+
46+
* :func:`tkinter.filedialog.askopenfiles` has been deprecated since Python
47+
3.16. Iterate over the names returned by
48+
:func:`~tkinter.filedialog.askopenfilenames` and open them one by one
49+
instead.
50+
(Contributed by Serhiy Storchaka in :gh:`152638`.)

0 commit comments

Comments
 (0)