Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9051248

Browse filesBrowse files
authored
Merge branch 'main' into issue-118033
2 parents 7c09ec8 + 2f4db5a commit 9051248
Copy full SHA for 9051248

File tree

Expand file treeCollapse file tree

651 files changed

+20599
-5964
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

651 files changed

+20599
-5964
lines changed

‎.github/workflows/build.yml

Copy file name to clipboardExpand all lines: .github/workflows/build.yml
+6-14Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,11 @@ on:
88
push:
99
branches:
1010
- 'main'
11-
- '3.12'
12-
- '3.11'
13-
- '3.10'
14-
- '3.9'
15-
- '3.8'
11+
- '3.*'
1612
pull_request:
1713
branches:
1814
- 'main'
19-
- '3.12'
20-
- '3.11'
21-
- '3.10'
22-
- '3.9'
23-
- '3.8'
15+
- '3.*'
2416

2517
permissions:
2618
contents: read
@@ -218,7 +210,7 @@ jobs:
218210
with:
219211
config_hash: ${{ needs.check_source.outputs.config_hash }}
220212
free-threading: true
221-
# macos-14 is M1
213+
# macos-14-large is Intel with 12 cores (most parallelism)
222214
os-matrix: '["macos-14"]'
223215

224216
build_ubuntu:
@@ -250,7 +242,7 @@ jobs:
250242
251243
build_ubuntu_ssltests:
252244
name: 'Ubuntu SSL tests with OpenSSL'
253-
runs-on: ubuntu-20.04
245+
runs-on: ubuntu-22.04
254246
timeout-minutes: 60
255247
needs: check_source
256248
if: needs.check_source.outputs.run_tests == 'true'
@@ -316,7 +308,7 @@ jobs:
316308

317309
test_hypothesis:
318310
name: "Hypothesis tests on Ubuntu"
319-
runs-on: ubuntu-20.04
311+
runs-on: ubuntu-22.04
320312
timeout-minutes: 60
321313
needs: check_source
322314
if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true'
@@ -429,7 +421,7 @@ jobs:
429421

430422
build_asan:
431423
name: 'Address sanitizer'
432-
runs-on: ubuntu-20.04
424+
runs-on: ubuntu-22.04
433425
timeout-minutes: 60
434426
needs: check_source
435427
if: needs.check_source.outputs.run_tests == 'true'

‎.github/workflows/jit.yml

Copy file name to clipboardExpand all lines: .github/workflows/jit.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
jit:
2424
name: ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }})
2525
runs-on: ${{ matrix.runner }}
26-
timeout-minutes: 75
26+
timeout-minutes: 90
2727
strategy:
2828
fail-fast: false
2929
matrix:

‎.github/workflows/mypy.yml

Copy file name to clipboardExpand all lines: .github/workflows/mypy.yml
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
pull_request:
99
paths:
1010
- ".github/workflows/mypy.yml"
11+
- "Lib/_pyrepl/**"
1112
- "Lib/test/libregrtest/**"
1213
- "Tools/build/generate_sbom.py"
1314
- "Tools/cases_generator/**"
@@ -35,8 +36,9 @@ jobs:
3536
strategy:
3637
matrix:
3738
target: [
39+
"Lib/_pyrepl",
3840
"Lib/test/libregrtest",
39-
"Tools/build/",
41+
"Tools/build",
4042
"Tools/cases_generator",
4143
"Tools/clinic",
4244
"Tools/jit",

‎.github/workflows/posix-deps-apt.sh

Copy file name to clipboardExpand all lines: .github/workflows/posix-deps-apt.sh
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ apt-get -yq install \
1515
libgdbm-dev \
1616
libgdbm-compat-dev \
1717
liblzma-dev \
18+
libmpdec-dev \
1819
libncurses5-dev \
1920
libreadline6-dev \
2021
libsqlite3-dev \

‎.github/workflows/reusable-macos.yml

Copy file name to clipboardExpand all lines: .github/workflows/reusable-macos.yml
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
HOMEBREW_NO_INSTALL_CLEANUP: 1
2323
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
2424
PYTHONSTRICTEXTENSIONBUILD: 1
25+
TERM: linux
2526
strategy:
2627
fail-fast: false
2728
matrix:
@@ -49,7 +50,7 @@ jobs:
4950
--prefix=/opt/python-dev \
5051
--with-openssl="$(brew --prefix openssl@3.0)"
5152
- name: Build CPython
52-
run: make -j4
53+
run: make -j8
5354
- name: Display build info
5455
run: make pythoninfo
5556
- name: Tests

‎.github/workflows/reusable-tsan.yml

Copy file name to clipboardExpand all lines: .github/workflows/reusable-tsan.yml
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ jobs:
2929
- name: Install Dependencies
3030
run: |
3131
sudo ./.github/workflows/posix-deps-apt.sh
32-
sudo apt install -y clang
32+
# Install clang-18
33+
wget https://apt.llvm.org/llvm.sh
34+
chmod +x llvm.sh
35+
sudo ./llvm.sh 18
36+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100
37+
sudo update-alternatives --set clang /usr/bin/clang-18
38+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100
39+
sudo update-alternatives --set clang++ /usr/bin/clang++-18
3340
# Reduce ASLR to avoid TSAN crashing
3441
sudo sysctl -w vm.mmap_rnd_bits=28
3542
- name: TSAN Option Setup

‎.github/workflows/reusable-ubuntu.yml

Copy file name to clipboardExpand all lines: .github/workflows/reusable-ubuntu.yml
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ jobs:
1212
build_ubuntu_reusable:
1313
name: 'build and test'
1414
timeout-minutes: 60
15-
runs-on: ubuntu-20.04
15+
runs-on: ubuntu-22.04
1616
env:
1717
FORCE_COLOR: 1
1818
OPENSSL_VER: 3.0.13
1919
PYTHONSTRICTEXTENSIONBUILD: 1
20+
TERM: linux
2021
steps:
2122
- uses: actions/checkout@v4
2223
- name: Register gcc problem matcher

‎.github/workflows/reusable-wasi.yml

Copy file name to clipboardExpand all lines: .github/workflows/reusable-wasi.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
build_wasi_reusable:
1010
name: 'build and test'
1111
timeout-minutes: 60
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-22.04
1313
env:
1414
WASMTIME_VERSION: 18.0.3
1515
WASI_SDK_VERSION: 21

‎Doc/c-api/frame.rst

Copy file name to clipboardExpand all lines: Doc/c-api/frame.rst
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,19 @@ See also :ref:`Reflection <reflection>`.
120120
121121
.. c:function:: PyObject* PyFrame_GetLocals(PyFrameObject *frame)
122122
123-
Get the *frame*'s :attr:`~frame.f_locals` attribute (:class:`dict`).
123+
Get the *frame*'s :attr:`~frame.f_locals` attribute.
124+
If the frame refers to a function or comprehension, this returns
125+
a write-through proxy object that allows modifying the locals.
126+
In all other cases (classes, modules) it returns the :class:`dict`
127+
representing the frame locals directly.
124128
125129
Return a :term:`strong reference`.
126130
127131
.. versionadded:: 3.11
128132
133+
.. versionchanged:: 3.13
134+
Return a proxy object for functions and comprehensions.
135+
129136
130137
.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
131138

‎Doc/c-api/index.rst

Copy file name to clipboardExpand all lines: Doc/c-api/index.rst
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ document the API functions in detail.
2525
memory.rst
2626
objimpl.rst
2727
apiabiversion.rst
28+
monitoring.rst

‎Doc/c-api/init_config.rst

Copy file name to clipboardExpand all lines: Doc/c-api/init_config.rst
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,11 @@ PyConfig
12501250
If non-zero, initialize the perf trampoline. See :ref:`perf_profiling`
12511251
for more information.
12521252
1253-
Set by :option:`-X perf <-X>` command line option and by the
1254-
:envvar:`PYTHONPERFSUPPORT` environment variable.
1253+
Set by :option:`-X perf <-X>` command-line option and by the
1254+
:envvar:`PYTHON_PERF_JIT_SUPPORT` environment variable for perf support
1255+
with stack pointers and :option:`-X perf_jit <-X>` command-line option
1256+
and by the :envvar:`PYTHON_PERF_JIT_SUPPORT` environment variable for perf
1257+
support with DWARF JIT information.
12551258
12561259
Default: ``-1``.
12571260

‎Doc/c-api/long.rst

Copy file name to clipboardExpand all lines: Doc/c-api/long.rst
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
390390
Usage example::
391391
392392
int32_t value;
393-
Py_ssize_t bytes = PyLong_AsNativeBits(pylong, &value, sizeof(value), -1);
393+
Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, &value, sizeof(value), -1);
394394
if (bytes < 0) {
395395
// Failed. A Python exception was set with the reason.
396396
return NULL;
@@ -418,7 +418,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
418418
called twice: first to determine the buffer size, then to fill it::
419419
420420
// Ask how much space we need.
421-
Py_ssize_t expected = PyLong_AsNativeBits(pylong, NULL, 0, -1);
421+
Py_ssize_t expected = PyLong_AsNativeBytes(pylong, NULL, 0, -1);
422422
if (expected < 0) {
423423
// Failed. A Python exception was set with the reason.
424424
return NULL;
@@ -430,7 +430,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
430430
return NULL;
431431
}
432432
// Safely get the entire value.
433-
Py_ssize_t bytes = PyLong_AsNativeBits(pylong, bignum, expected, -1);
433+
Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, bignum, expected, -1);
434434
if (bytes < 0) { // Exception has been set.
435435
free(bignum);
436436
return NULL;

‎Doc/c-api/module.rst

Copy file name to clipboardExpand all lines: Doc/c-api/module.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ state:
634634
635635
.. versionadded:: 3.9
636636
637-
.. c:function:: int PyModule_ExperimentalSetGIL(PyObject *module, void *gil)
637+
.. c:function:: int PyUnstable_Module_SetGIL(PyObject *module, void *gil)
638638
639639
Indicate that *module* does or does not support running without the global
640640
interpreter lock (GIL), using one of the values from

‎Doc/c-api/monitoring.rst

Copy file name to clipboard
+164Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
.. highlight:: c
2+
3+
.. _monitoring:
4+
5+
Monitorong C API
6+
================
7+
8+
Added in version 3.13.
9+
10+
An extension may need to interact with the event monitoring system. Subscribing
11+
to events and registering callbacks can be done via the Python API exposed in
12+
:mod:`sys.monitoring`.
13+
14+
Generating Execution Events
15+
===========================
16+
17+
The functions below make it possible for an extension to fire monitoring
18+
events as it emulates the execution of Python code. Each of these functions
19+
accepts a ``PyMonitoringState`` struct which contains concise information
20+
about the activation state of events, as well as the event arguments, which
21+
include a ``PyObject*`` representing the code object, the instruction offset
22+
and sometimes additional, event-specific arguments (see :mod:`sys.monitoring`
23+
for details about the signatures of the different event callbacks).
24+
The ``codelike`` argument should be an instance of :class:`types.CodeType`
25+
or of a type that emulates it.
26+
27+
The VM disables tracing when firing an event, so there is no need for user
28+
code to do that.
29+
30+
Monitoring functions should not be called with an exception set,
31+
except those listed below as working with the current exception.
32+
33+
.. c:type:: PyMonitoringState
34+
35+
Representation of the state of an event type. It is allocated by the user
36+
while its contents are maintained by the monitoring API functions described below.
37+
38+
39+
All of the functions below return 0 on success and -1 (with an exception set) on error.
40+
41+
See :mod:`sys.monitoring` for descriptions of the events.
42+
43+
.. c:function:: int PyMonitoring_FirePyStartEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset)
44+
45+
Fire a ``PY_START`` event.
46+
47+
48+
.. c:function:: int PyMonitoring_FirePyResumeEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset)
49+
50+
Fire a ``PY_RESUME`` event.
51+
52+
53+
.. c:function:: int PyMonitoring_FirePyReturnEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject* retval)
54+
55+
Fire a ``PY_RETURN`` event.
56+
57+
58+
.. c:function:: int PyMonitoring_FirePyYieldEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject* retval)
59+
60+
Fire a ``PY_YIELD`` event.
61+
62+
63+
.. c:function:: int PyMonitoring_FireCallEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject* callable, PyObject *arg0)
64+
65+
Fire a ``CALL`` event.
66+
67+
68+
.. c:function:: int PyMonitoring_FireLineEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, int lineno)
69+
70+
Fire a ``LINE`` event.
71+
72+
73+
.. c:function:: int PyMonitoring_FireJumpEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *target_offset)
74+
75+
Fire a ``JUMP`` event.
76+
77+
78+
.. c:function:: int PyMonitoring_FireBranchEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *target_offset)
79+
80+
Fire a ``BRANCH`` event.
81+
82+
83+
.. c:function:: int PyMonitoring_FireCReturnEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *retval)
84+
85+
Fire a ``C_RETURN`` event.
86+
87+
88+
.. c:function:: int PyMonitoring_FirePyThrowEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset)
89+
90+
Fire a ``PY_THROW`` event with the current exception (as returned by
91+
:c:func:`PyErr_GetRaisedException`).
92+
93+
94+
.. c:function:: int PyMonitoring_FireRaiseEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset)
95+
96+
Fire a ``RAISE`` event with the current exception (as returned by
97+
:c:func:`PyErr_GetRaisedException`).
98+
99+
100+
.. c:function:: int PyMonitoring_FireCRaiseEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset)
101+
102+
Fire a ``C_RAISE`` event with the current exception (as returned by
103+
:c:func:`PyErr_GetRaisedException`).
104+
105+
106+
.. c:function:: int PyMonitoring_FireReraiseEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset)
107+
108+
Fire a ``RERAISE`` event with the current exception (as returned by
109+
:c:func:`PyErr_GetRaisedException`).
110+
111+
112+
.. c:function:: int PyMonitoring_FireExceptionHandledEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset)
113+
114+
Fire an ``EXCEPTION_HANDLED`` event with the current exception (as returned by
115+
:c:func:`PyErr_GetRaisedException`).
116+
117+
118+
.. c:function:: int PyMonitoring_FirePyUnwindEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset)
119+
120+
Fire a ``PY_UNWIND`` event with the current exception (as returned by
121+
:c:func:`PyErr_GetRaisedException`).
122+
123+
124+
.. c:function:: int PyMonitoring_FireStopIterationEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset)
125+
126+
Fire a ``STOP_ITERATION`` event with the current exception (as returned by
127+
:c:func:`PyErr_GetRaisedException`).
128+
129+
130+
Managing the Monitoring State
131+
-----------------------------
132+
133+
Monitoring states can be managed with the help of monitoring scopes. A scope
134+
would typically correspond to a python function.
135+
136+
.. :c:function:: int PyMonitoring_EnterScope(PyMonitoringState *state_array, uint64_t *version, const uint8_t *event_types, Py_ssize_t length)
137+
138+
Enter a monitored scope. ``event_types`` is an array of the event IDs for
139+
events that may be fired from the scope. For example, the ID of a ``PY_START``
140+
event is the value ``PY_MONITORING_EVENT_PY_START``, which is numerically equal
141+
to the base-2 logarithm of ``sys.monitoring.events.PY_START``.
142+
``state_array`` is an array with a monitoring state entry for each event in
143+
``event_types``, it is allocated by the user but populated by
144+
``PyMonitoring_EnterScope`` with information about the activation state of
145+
the event. The size of ``event_types`` (and hence also of ``state_array``)
146+
is given in ``length``.
147+
148+
The ``version`` argument is a pointer to a value which should be allocated
149+
by the user together with ``state_array`` and initialized to 0,
150+
and then set only by ``PyMonitoring_EnterScope`` itelf. It allows this
151+
function to determine whether event states have changed since the previous call,
152+
and to return quickly if they have not.
153+
154+
The scopes referred to here are lexical scopes: a function, class or method.
155+
``PyMonitoring_EnterScope`` should be called whenever the lexical scope is
156+
entered. Scopes can be reentered, reusing the same *state_array* and *version*,
157+
in situations like when emulating a recursive Python function. When a code-like's
158+
execution is paused, such as when emulating a generator, the scope needs to
159+
be exited and re-entered.
160+
161+
162+
.. :c:function:: int PyMonitoring_ExitScope(void)
163+
164+
Exit the last scope that was entered with ``PyMonitoring_EnterScope``.

‎Doc/c-api/object.rst

Copy file name to clipboardExpand all lines: Doc/c-api/object.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Object Protocol
6565
6666
Properly handle returning :c:data:`Py_NotImplemented` from within a C
6767
function (that is, create a new :term:`strong reference`
68-
to NotImplemented and return it).
68+
to :const:`NotImplemented` and return it).
6969
7070
7171
.. c:macro:: Py_PRINT_RAW

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.