Skip to content

Commit 783700d

Browse files
authored
Merge branch 'main' into configure-pgo-O0
2 parents 69d1659 + 5ae8b97 commit 783700d

File tree

134 files changed

+5074
-1881
lines changed

Some content is hidden

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

134 files changed

+5074
-1881
lines changed

.github/CODEOWNERS

Lines changed: 532 additions & 291 deletions
Large diffs are not rendered by default.

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ jobs:
270270
fail-fast: false
271271
matrix:
272272
os: [ubuntu-24.04]
273-
openssl_ver: [3.0.17, 3.2.5, 3.3.4, 3.4.2, 3.5.2]
273+
# Keep 1.1.1w in our list despite it being upstream EOL and otherwise
274+
# unsupported as it most resembles other 1.1.1-work-a-like ssl APIs
275+
# supported by important vendors such as AWS-LC.
276+
openssl_ver: [1.1.1w, 3.0.17, 3.2.5, 3.3.4, 3.4.2, 3.5.2]
274277
# See Tools/ssl/make_ssl_data.py for notes on adding a new version
275278
env:
276279
OPENSSL_VER: ${{ matrix.openssl_ver }}

.github/workflows/tail-call.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ jobs:
114114
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
115115
brew install llvm@${{ matrix.llvm }}
116116
export SDKROOT="$(xcrun --show-sdk-path)"
117-
export PATH="/usr/local/opt/llvm/bin:$PATH"
118-
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
117+
export PATH="/usr/local/opt/llvm@${{ matrix.llvm }}/bin:$PATH"
118+
export PATH="/opt/homebrew/opt/llvm@${{ matrix.llvm }}/bin:$PATH"
119119
CC=clang-20 ./configure --with-tail-call-interp
120120
make all --jobs 4
121121
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ iOS/testbed/Python.xcframework/ios-*/lib
8080
iOS/testbed/Python.xcframework/ios-*/Python.framework
8181
iOS/testbed/iOSTestbed.xcodeproj/project.xcworkspace
8282
iOS/testbed/iOSTestbed.xcodeproj/xcuserdata
83-
iOS/testbed/iOSTestbed.xcodeproj/xcshareddata
8483
Mac/Makefile
8584
Mac/PythonLauncher/Info.plist
8685
Mac/PythonLauncher/Makefile

Doc/c-api/dict.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,15 @@ Dictionary Objects
301301
}
302302
Py_END_CRITICAL_SECTION();
303303
304+
.. note::
305+
306+
On the free-threaded build, this function can be used safely inside a
307+
critical section. However, the references returned for *pkey* and *pvalue*
308+
are :term:`borrowed <borrowed reference>` and are only valid while the
309+
critical section is held. If you need to use these objects outside the
310+
critical section or when the critical section can be suspended, create a
311+
:term:`strong reference <strong reference>` (for example, using
312+
:c:func:`Py_NewRef`).
304313
305314
.. c:function:: int PyDict_Merge(PyObject *a, PyObject *b, int override)
306315

Doc/c-api/init.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,12 +2299,20 @@ per-object locks for :term:`free-threaded <free threading>` CPython. They are
22992299
intended to replace reliance on the :term:`global interpreter lock`, and are
23002300
no-ops in versions of Python with the global interpreter lock.
23012301
2302+
Critical sections are intended to be used for custom types implemented
2303+
in C-API extensions. They should generally not be used with built-in types like
2304+
:class:`list` and :class:`dict` because their public C-APIs
2305+
already use critical sections internally, with the notable
2306+
exception of :c:func:`PyDict_Next`, which requires critical section
2307+
to be acquired externally.
2308+
23022309
Critical sections avoid deadlocks by implicitly suspending active critical
2303-
sections and releasing the locks during calls to :c:func:`PyEval_SaveThread`.
2304-
When :c:func:`PyEval_RestoreThread` is called, the most recent critical section
2305-
is resumed, and its locks reacquired. This means the critical section API
2306-
provides weaker guarantees than traditional locks -- they are useful because
2307-
their behavior is similar to the :term:`GIL`.
2310+
sections, hence, they do not provide exclusive access such as provided by
2311+
traditional locks like :c:type:`PyMutex`. When a critical section is started,
2312+
the per-object lock for the object is acquired. If the code executed inside the
2313+
critical section calls C-API functions then it can suspend the critical section thereby
2314+
releasing the per-object lock, so other threads can acquire the per-object lock
2315+
for the same object.
23082316
23092317
Variants that accept :c:type:`PyMutex` pointers rather than Python objects are also
23102318
available. Use these variants to start a critical section in a situation where

Doc/c-api/typeobj.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,19 @@ and :c:data:`PyType_Type` effectively act as defaults.)
12861286
:c:member:`~PyTypeObject.tp_weaklistoffset` field is set in a superclass.
12871287

12881288

1289+
.. c:macro:: Py_TPFLAGS_PREHEADER
1290+
1291+
These bits indicate that the VM will manage some fields by storing them
1292+
before the object. Currently, this macro is equivalent to
1293+
:c:expr:`Py_TPFLAGS_MANAGED_DICT | Py_TPFLAGS_MANAGED_WEAKREF`.
1294+
1295+
This macro value relies on the implementation of the VM, so its value is not
1296+
stable and may change in a future version. Prefer using individual
1297+
flags instead.
1298+
1299+
.. versionadded:: 3.12
1300+
1301+
12891302
.. c:macro:: Py_TPFLAGS_ITEMS_AT_END
12901303
12911304
Only usable with variable-size types, i.e. ones with non-zero

Doc/extending/extending.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,14 @@ references to all its items, so when item 1 is replaced, it has to dispose of
10841084
the original item 1. Now let's suppose the original item 1 was an instance of a
10851085
user-defined class, and let's further suppose that the class defined a
10861086
:meth:`!__del__` method. If this class instance has a reference count of 1,
1087-
disposing of it will call its :meth:`!__del__` method.
1087+
disposing of it will call its :meth:`!__del__` method. Internally,
1088+
:c:func:`PyList_SetItem` calls :c:func:`Py_DECREF` on the replaced item,
1089+
which invokes replaced item's corresponding
1090+
:c:member:`~PyTypeObject.tp_dealloc` function. During
1091+
deallocation, :c:member:`~PyTypeObject.tp_dealloc` calls
1092+
:c:member:`~PyTypeObject.tp_finalize`, which is mapped to the
1093+
:meth:`!__del__` method for class instances (see :pep:`442`). This entire
1094+
sequence happens synchronously within the :c:func:`PyList_SetItem` call.
10881095

10891096
Since it is written in Python, the :meth:`!__del__` method can execute arbitrary
10901097
Python code. Could it perhaps do something to invalidate the reference to

Doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Glossary
107107
statements.
108108

109109
asynchronous generator iterator
110-
An object created by a :term:`asynchronous generator` function.
110+
An object created by an :term:`asynchronous generator` function.
111111

112112
This is an :term:`asynchronous iterator` which when called using the
113113
:meth:`~object.__anext__` method returns an awaitable object which will execute

Doc/library/_thread.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,16 @@ This module defines the following constants and functions:
120120
Its value may be used to uniquely identify this particular thread system-wide
121121
(until the thread terminates, after which the value may be recycled by the OS).
122122

123-
.. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD, NetBSD, AIX, DragonFlyBSD, GNU/kFreeBSD.
123+
.. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD, NetBSD, AIX, DragonFlyBSD, GNU/kFreeBSD, Solaris.
124124

125125
.. versionadded:: 3.8
126126

127127
.. versionchanged:: 3.13
128128
Added support for GNU/kFreeBSD.
129129

130+
.. versionchanged:: next
131+
Added support for Solaris.
132+
130133

131134
.. function:: stack_size([size])
132135

0 commit comments

Comments
 (0)