Skip to content

Commit 20bb910

Browse files
committed
Merge branch 'main' of https://github.com/python/cpython into is-immortal-sys
2 parents 638edd0 + d8e16ef commit 20bb910

File tree

205 files changed

+7816
-3236
lines changed

Some content is hidden

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

205 files changed

+7816
-3236
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ concurrency:
1818
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-reusable
1919
cancel-in-progress: true
2020

21+
env:
22+
FORCE_COLOR: 1
23+
2124
jobs:
2225
check_source:
2326
name: Change detection

.github/workflows/jit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ concurrency:
2525
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
2626
cancel-in-progress: true
2727

28+
env:
29+
FORCE_COLOR: 1
30+
2831
jobs:
2932
interpreter:
3033
name: Interpreter (Debug)

.github/workflows/reusable-macos.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ on:
1515
required: true
1616
type: string
1717

18+
env:
19+
FORCE_COLOR: 1
20+
1821
jobs:
1922
build_macos:
2023
name: build and test (${{ inputs.os }})

.github/workflows/reusable-tsan.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ on:
1818
required: true
1919
type: string
2020

21+
env:
22+
FORCE_COLOR: 1
23+
2124
jobs:
2225
build_tsan_reusable:
2326
name: 'Thread sanitizer'

.github/workflows/reusable-ubuntu.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ on:
2121
required: true
2222
type: string
2323

24+
env:
25+
FORCE_COLOR: 1
26+
2427
jobs:
2528
build_ubuntu_reusable:
2629
name: build and test (${{ inputs.os }})
2730
timeout-minutes: 60
2831
runs-on: ${{ inputs.os }}
2932
env:
30-
FORCE_COLOR: 1
3133
OPENSSL_VER: 3.0.15
3234
PYTHONSTRICTEXTENSIONBUILD: 1
3335
TERM: linux

.github/workflows/reusable-wasi.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
required: true
88
type: string
99

10+
env:
11+
FORCE_COLOR: 1
12+
1013
jobs:
1114
build_wasi_reusable:
1215
name: 'build and test'

.github/workflows/reusable-windows-msi.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
permissions:
1212
contents: read
1313

14+
env:
15+
FORCE_COLOR: 1
16+
1417
jobs:
1518
build:
1619
name: installer for ${{ inputs.arch }}

.github/workflows/reusable-windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ on:
1818
default: false
1919

2020
env:
21+
FORCE_COLOR: 1
2122
IncludeUwp: >-
2223
true
2324

Android/android-env.sh

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# This script must be sourced with the following variables already set:
2-
: ${ANDROID_HOME:?} # Path to Android SDK
3-
: ${HOST:?} # GNU target triplet
2+
: "${ANDROID_HOME:?}" # Path to Android SDK
3+
: "${HOST:?}" # GNU target triplet
44

55
# You may also override the following:
6-
: ${api_level:=24} # Minimum Android API level the build will run on
7-
: ${PREFIX:-} # Path in which to find required libraries
6+
: "${api_level:=24}" # Minimum Android API level the build will run on
7+
: "${PREFIX:-}" # Path in which to find required libraries
88

99

1010
# Print all messages on stderr so they're visible when running within build-wheel.
@@ -27,20 +27,20 @@ fail() {
2727
ndk_version=27.1.12297006
2828

2929
ndk=$ANDROID_HOME/ndk/$ndk_version
30-
if ! [ -e $ndk ]; then
30+
if ! [ -e "$ndk" ]; then
3131
log "Installing NDK - this may take several minutes"
32-
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "ndk;$ndk_version"
32+
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "ndk;$ndk_version"
3333
fi
3434

35-
if [ $HOST = "arm-linux-androideabi" ]; then
35+
if [ "$HOST" = "arm-linux-androideabi" ]; then
3636
clang_triplet=armv7a-linux-androideabi
3737
else
38-
clang_triplet=$HOST
38+
clang_triplet="$HOST"
3939
fi
4040

4141
# These variables are based on BuildSystemMaintainers.md above, and
4242
# $ndk/build/cmake/android.toolchain.cmake.
43-
toolchain=$(echo $ndk/toolchains/llvm/prebuilt/*)
43+
toolchain=$(echo "$ndk"/toolchains/llvm/prebuilt/*)
4444
export AR="$toolchain/bin/llvm-ar"
4545
export AS="$toolchain/bin/llvm-as"
4646
export CC="$toolchain/bin/${clang_triplet}${api_level}-clang"
@@ -72,12 +72,12 @@ LDFLAGS="$LDFLAGS -lm"
7272

7373
# -mstackrealign is included where necessary in the clang launcher scripts which are
7474
# pointed to by $CC, so we don't need to include it here.
75-
if [ $HOST = "arm-linux-androideabi" ]; then
75+
if [ "$HOST" = "arm-linux-androideabi" ]; then
7676
CFLAGS="$CFLAGS -march=armv7-a -mthumb"
7777
fi
7878

7979
if [ -n "${PREFIX:-}" ]; then
80-
abs_prefix=$(realpath $PREFIX)
80+
abs_prefix="$(realpath "$PREFIX")"
8181
CFLAGS="$CFLAGS -I$abs_prefix/include"
8282
LDFLAGS="$LDFLAGS -L$abs_prefix/lib"
8383

@@ -87,11 +87,13 @@ fi
8787

8888
# When compiling C++, some build systems will combine CFLAGS and CXXFLAGS, and some will
8989
# use CXXFLAGS alone.
90-
export CXXFLAGS=$CFLAGS
90+
export CXXFLAGS="$CFLAGS"
9191

9292
# Use the same variable name as conda-build
93-
if [ $(uname) = "Darwin" ]; then
94-
export CPU_COUNT=$(sysctl -n hw.ncpu)
93+
if [ "$(uname)" = "Darwin" ]; then
94+
CPU_COUNT="$(sysctl -n hw.ncpu)"
95+
export CPU_COUNT
9596
else
96-
export CPU_COUNT=$(nproc)
97+
CPU_COUNT="$(nproc)"
98+
export CPU_COUNT
9799
fi

Doc/c-api/long.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,6 @@ The :c:type:`PyLongWriter` API can be used to import an integer.
824824
825825
Discard a :c:type:`PyLongWriter` created by :c:func:`PyLongWriter_Create`.
826826
827-
*writer* must not be ``NULL``.
827+
If *writer* is ``NULL``, no operation is performed.
828828
829829
The writer instance and the *digits* array are invalid after the call.

Doc/c-api/object.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,3 +613,14 @@ Object Protocol
613613
614614
.. versionadded:: 3.14
615615
616+
.. c:function:: int PyUnstable_IsImmortal(PyObject *obj)
617+
618+
This function returns non-zero if *obj* is :term:`immortal`, and zero
619+
otherwise. This function cannot fail.
620+
621+
.. note::
622+
623+
Objects that are immortal in one CPython version are not guaranteed to
624+
be immortal in another.
625+
626+
.. versionadded:: next

Doc/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,6 @@
560560
r'https://github.com/python/cpython/tree/.*': 'https://github.com/python/cpython/blob/.*',
561561
# Intentional HTTP use at Misc/NEWS.d/3.5.0a1.rst
562562
r'http://www.python.org/$': 'https://www.python.org/$',
563-
# Used in license page, keep as is
564-
r'https://www.zope.org/': r'https://www.zope.dev/',
565563
# Microsoft's redirects to learn.microsoft.com
566564
r'https://msdn.microsoft.com/.*': 'https://learn.microsoft.com/.*',
567565
r'https://docs.microsoft.com/.*': 'https://learn.microsoft.com/.*',

Doc/deprecations/c-api-pending-removal-in-3.18.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Pending removal in Python 3.18
66
* :c:func:`!_PyBytes_Join`: use :c:func:`PyBytes_Join`.
77
* :c:func:`!_PyDict_GetItemStringWithError`: use :c:func:`PyDict_GetItemStringRef`.
88
* :c:func:`!_PyDict_Pop()`: :c:func:`PyDict_Pop`.
9+
* :c:func:`!_PyLong_Sign()`: use :c:func:`PyLong_GetSign`.
10+
* :c:func:`!_PyLong_FromDigits` and :c:func:`!_PyLong_New`:
11+
use :c:func:`PyLongWriter_Create`.
912
* :c:func:`!_PyThreadState_UncheckedGet`: use :c:func:`PyThreadState_GetUnchecked`.
1013
* :c:func:`!_PyUnicode_AsString`: use :c:func:`PyUnicode_AsUTF8`.
1114
* :c:func:`!_Py_HashPointer`: use :c:func:`Py_HashPointer`.

Doc/deprecations/c-api-pending-removal-in-future.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ although there is currently no date scheduled for their removal.
3434
Use :c:func:`!_PyErr_ChainExceptions1` instead.
3535
* :c:member:`!PyBytesObject.ob_shash` member:
3636
call :c:func:`PyObject_Hash` instead.
37-
* :c:member:`!PyDictObject.ma_version_tag` member.
3837
* Thread Local Storage (TLS) API:
3938

4039
* :c:func:`PyThread_create_key`:

Doc/library/asyncio-graph.rst

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
.. currentmodule:: asyncio
2+
3+
4+
.. _asyncio-graph:
5+
6+
========================
7+
Call Graph Introspection
8+
========================
9+
10+
**Source code:** :source:`Lib/asyncio/graph.py`
11+
12+
-------------------------------------
13+
14+
asyncio has powerful runtime call graph introspection utilities
15+
to trace the entire call graph of a running *coroutine* or *task*, or
16+
a suspended *future*. These utilities and the underlying machinery
17+
can be used from within a Python program or by external profilers
18+
and debuggers.
19+
20+
.. versionadded:: next
21+
22+
23+
.. function:: print_call_graph(future=None, /, *, file=None, depth=1, limit=None)
24+
25+
Print the async call graph for the current task or the provided
26+
:class:`Task` or :class:`Future`.
27+
28+
This function prints entries starting from the top frame and going
29+
down towards the invocation point.
30+
31+
The function receives an optional *future* argument.
32+
If not passed, the current running task will be used.
33+
34+
If the function is called on *the current task*, the optional
35+
keyword-only *depth* argument can be used to skip the specified
36+
number of frames from top of the stack.
37+
38+
If the optional keyword-only *limit* argument is provided, each call stack
39+
in the resulting graph is truncated to include at most ``abs(limit)``
40+
entries. If *limit* is positive, the entries left are the closest to
41+
the invocation point. If *limit* is negative, the topmost entries are
42+
left. If *limit* is omitted or ``None``, all entries are present.
43+
If *limit* is ``0``, the call stack is not printed at all, only
44+
"awaited by" information is printed.
45+
46+
If *file* is omitted or ``None``, the function will print
47+
to :data:`sys.stdout`.
48+
49+
**Example:**
50+
51+
The following Python code:
52+
53+
.. code-block:: python
54+
55+
import asyncio
56+
57+
async def test():
58+
asyncio.print_call_graph()
59+
60+
async def main():
61+
async with asyncio.TaskGroup() as g:
62+
g.create_task(test(), name='test')
63+
64+
asyncio.run(main())
65+
66+
will print::
67+
68+
* Task(name='test', id=0x1039f0fe0)
69+
+ Call stack:
70+
| File 't2.py', line 4, in async test()
71+
+ Awaited by:
72+
* Task(name='Task-1', id=0x103a5e060)
73+
+ Call stack:
74+
| File 'taskgroups.py', line 107, in async TaskGroup.__aexit__()
75+
| File 't2.py', line 7, in async main()
76+
77+
.. function:: format_call_graph(future=None, /, *, depth=1, limit=None)
78+
79+
Like :func:`print_call_graph`, but returns a string.
80+
If *future* is ``None`` and there's no current task,
81+
the function returns an empty string.
82+
83+
84+
.. function:: capture_call_graph(future=None, /, *, depth=1, limit=None)
85+
86+
Capture the async call graph for the current task or the provided
87+
:class:`Task` or :class:`Future`.
88+
89+
The function receives an optional *future* argument.
90+
If not passed, the current running task will be used. If there's no
91+
current task, the function returns ``None``.
92+
93+
If the function is called on *the current task*, the optional
94+
keyword-only *depth* argument can be used to skip the specified
95+
number of frames from top of the stack.
96+
97+
Returns a ``FutureCallGraph`` data class object:
98+
99+
* ``FutureCallGraph(future, call_stack, awaited_by)``
100+
101+
Where *future* is a reference to a :class:`Future` or
102+
a :class:`Task` (or their subclasses.)
103+
104+
``call_stack`` is a tuple of ``FrameCallGraphEntry`` objects.
105+
106+
``awaited_by`` is a tuple of ``FutureCallGraph`` objects.
107+
108+
* ``FrameCallGraphEntry(frame)``
109+
110+
Where *frame* is a frame object of a regular Python function
111+
in the call stack.
112+
113+
114+
Low level utility functions
115+
===========================
116+
117+
To introspect an async call graph asyncio requires cooperation from
118+
control flow structures, such as :func:`shield` or :class:`TaskGroup`.
119+
Any time an intermediate :class:`Future` object with low-level APIs like
120+
:meth:`Future.add_done_callback() <asyncio.Future.add_done_callback>` is
121+
involved, the following two functions should be used to inform asyncio
122+
about how exactly such intermediate future objects are connected with
123+
the tasks they wrap or control.
124+
125+
126+
.. function:: future_add_to_awaited_by(future, waiter, /)
127+
128+
Record that *future* is awaited on by *waiter*.
129+
130+
Both *future* and *waiter* must be instances of
131+
:class:`Future` or :class:`Task` or their subclasses,
132+
otherwise the call would have no effect.
133+
134+
A call to ``future_add_to_awaited_by()`` must be followed by an
135+
eventual call to the :func:`future_discard_from_awaited_by` function
136+
with the same arguments.
137+
138+
139+
.. function:: future_discard_from_awaited_by(future, waiter, /)
140+
141+
Record that *future* is no longer awaited on by *waiter*.
142+
143+
Both *future* and *waiter* must be instances of
144+
:class:`Future` or :class:`Task` or their subclasses, otherwise
145+
the call would have no effect.

Doc/library/asyncio.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ You can experiment with an ``asyncio`` concurrent context in the :term:`REPL`:
9999
asyncio-subprocess.rst
100100
asyncio-queue.rst
101101
asyncio-exceptions.rst
102+
asyncio-graph.rst
102103

103104
.. toctree::
104105
:caption: Low-level APIs

0 commit comments

Comments
 (0)