Skip to content

Commit af10777

Browse files
authored
Merge branch 'main' into feat/codecs/surrogate-escape-handler-129173
2 parents 758b84e + 6e63c47 commit af10777

File tree

158 files changed

+6112
-2569
lines changed

Some content is hidden

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

158 files changed

+6112
-2569
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
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Pending removal in Python 3.18
2+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3+
4+
* Deprecated private functions (:gh:`128863`):
5+
6+
* :c:func:`!_PyBytes_Join`: use :c:func:`PyBytes_Join`.
7+
* :c:func:`!_PyDict_GetItemStringWithError`: use :c:func:`PyDict_GetItemStringRef`.
8+
* :c:func:`!_PyDict_Pop()`: :c:func:`PyDict_Pop`.
9+
* :c:func:`!_PyLong_Sign()`: use :c:func:`PyLong_GetSign`.
10+
* :c:func:`!_PyLong_New`: use :c:func:`PyLongWriter_Create`.
11+
* :c:func:`!_PyThreadState_UncheckedGet`: use :c:func:`PyThreadState_GetUnchecked`.
12+
* :c:func:`!_PyUnicode_AsString`: use :c:func:`PyUnicode_AsUTF8`.
13+
* :c:func:`!_Py_HashPointer`: use :c:func:`Py_HashPointer`.
14+
* :c:func:`!_Py_fopen_obj`: use :c:func:`Py_fopen`.
15+
16+
The `pythoncapi-compat project
17+
<https://github.com/python/pythoncapi-compat/>`__ can be used to get these
18+
new public functions on Python 3.13 and older.

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.

0 commit comments

Comments
 (0)