Skip to content

Commit e4f54de

Browse files
authored
Merge branch 'main' into gh-builtit-bug
2 parents 290838c + 02fae7a commit e4f54de

125 files changed

Lines changed: 5395 additions & 2868 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/reusable-wasi.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-26.04-arm
1616
timeout-minutes: 60
1717
env:
18-
WASMTIME_VERSION: 38.0.3
18+
WASMTIME_VERSION: 48.0.2
1919
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
2020
steps:
2121
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

‎.pre-commit-config.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ repos:
143143
entry: Space found in path, move to Misc/NEWS.d/next/Core_and_Builtins/
144144
files: Misc/NEWS.d/next/Core and Builtins/20.*.rst
145145

146+
- repo: local
147+
hooks:
148+
- id: check-capi-macros
149+
name: Check C API macros start with Py
150+
language: python
151+
entry: python Tools/build/check_capi_macros.py
152+
pass_filenames: false
153+
files: ^(Include/(cpython/)?[^/]+\.h|pyconfig\.h\.in|Tools/build/check_capi_macros)
154+
146155
- repo: meta
147156
hooks:
148157
- id: check-hooks-apply

‎Doc/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ lock:
191191
# Dependencies have a 14 day cooldown period to mitigate supply chain attacks,
192192
# except for sphinx_linklint and python-docs-theme, which are maintained by
193193
# core team members.
194-
uv pip compile requirements.txt \
195-
--exclude-newer P14D \
194+
$(UV) pip compile requirements.txt \
195+
--upgrade --exclude-newer P14D \
196196
--exclude-newer-package sphinx_linklint=PT0S \
197197
--exclude-newer-package python-docs-theme=PT0S \
198198
--no-cache --output-file $(REQUIREMENTS) \

‎Doc/c-api/unicode.rst‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ points must be below 1114112 (which is the full Unicode range).
1616

1717
UTF-8 representation is created on demand and cached in the Unicode object.
1818

19+
.. impl-detail::
20+
21+
The internal buffer always includes an extra trailing null character for
22+
compatibility with null terminated C strings. This extra character is not
23+
counted in :c:func:`PyUnicode_GetLength` nor in the various *size* arguments
24+
of the functions below.
25+
1926
.. note::
2027
The :c:type:`Py_UNICODE` representation has been removed since Python 3.12
2128
with deprecated APIs.
@@ -164,11 +171,15 @@ access to internal read-only data of Unicode objects:
164171
.. versionadded:: 3.3
165172
166173
167-
.. c:function:: Py_UCS4 PyUnicode_READ(int kind, void *data, \
168-
Py_ssize_t index)
174+
.. c:function:: Py_UCS4 PyUnicode_READ(int kind, void *data, Py_ssize_t index)
169175
170176
Read a code point from a canonical representation *data* (as obtained with
171-
:c:func:`PyUnicode_DATA`). No checks or ready calls are performed.
177+
:c:func:`PyUnicode_DATA`). No checks are performed.
178+
179+
.. impl-detail::
180+
181+
Accept reading the trailing null character at index
182+
:c:func:`PyUnicode_GetLength`.
172183
173184
.. versionadded:: 3.3
174185
@@ -179,6 +190,11 @@ access to internal read-only data of Unicode objects:
179190
representation. This is less efficient than :c:func:`PyUnicode_READ` if you
180191
do multiple consecutive reads.
181192
193+
.. impl-detail::
194+
195+
Accept reading the trailing null character at index
196+
:c:func:`PyUnicode_GetLength`.
197+
182198
.. versionadded:: 3.3
183199
184200
@@ -716,6 +732,10 @@ APIs:
716732
717733
On error, set an exception and return ``-1``.
718734
735+
.. impl-detail::
736+
737+
The length does not count the trailing null character.
738+
719739
.. versionadded:: 3.3
720740
721741
@@ -794,6 +814,11 @@ APIs:
794814
795815
Return character on success, ``-1`` on error with an exception set.
796816
817+
.. impl-detail::
818+
819+
Do not accept reading the trailing null character at index
820+
:c:func:`PyUnicode_GetLength`.
821+
797822
.. versionadded:: 3.3
798823
799824

‎Doc/conf.py‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,3 +636,40 @@
636636
"library/threadsafety.rst": "builtins/threadsafety.rst",
637637
"library/time-complexity.rst": "builtins/time-complexity.rst",
638638
}
639+
640+
# Refuse to run the doctest builder under a mismatched Python
641+
# -----------------------------------------------------------
642+
643+
644+
def _check_doctest_interpreter(app):
645+
# The doctests are executed by the interpreter running Sphinx,
646+
# so refuse to run them if its version doesn't match the source tree.
647+
if app.builder.name != "doctest":
648+
return
649+
650+
running_version = f"{sys.version_info.major}.{sys.version_info.minor}"
651+
if running_version != version:
652+
from sphinx.util import logging as sphinx_logging
653+
654+
logger = sphinx_logging.getLogger(__name__)
655+
logger.error(
656+
"The doctests are executed by the Python running Sphinx, "
657+
"which is Python %s, however this source tree is Python %s, "
658+
"so they would test Python %s rather than the code "
659+
"documented here.\n"
660+
"Recreate the venv with a matching interpreter, for example: "
661+
"'make clean-venv && make venv PYTHON=../python'.",
662+
running_version,
663+
version,
664+
running_version,
665+
)
666+
raise SystemExit(1)
667+
668+
669+
def setup(app):
670+
app.connect("builder-inited", _check_doctest_interpreter)
671+
return {
672+
"version": "1.0",
673+
"parallel_read_safe": True,
674+
"parallel_write_safe": True,
675+
}

‎Doc/library/asyncio-task.rst‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ other coroutines::
175175
* a *coroutine object*: an object returned by calling a
176176
*coroutine function*.
177177

178+
Generator-based coroutines, created with :func:`types.coroutine`, are
179+
covered by neither term and are not supported by asyncio.
180+
178181

179182
.. rubric:: Tasks
180183

@@ -1220,6 +1223,10 @@ Introspection
12201223

12211224
.. versionadded:: 3.4
12221225

1226+
.. versionchanged:: 3.12
1227+
Generator-based coroutines are no longer supported, and ``False``
1228+
is returned for them.
1229+
12231230
.. _asyncio-task-obj:
12241231

12251232
Task object

‎Doc/library/ctypes.rst‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,15 @@ Generally you only use this feature if you receive a pointer from a C function,
997997
and you *know* that the pointer actually points to an array instead of a single
998998
item.
999999

1000+
.. warning::
1001+
1002+
Because pointer objects support subscription, they implicitly support
1003+
:term:`iteration <iterator>`. Unless doing this in a controlled manner,
1004+
such as by manually calling :func:`next` on a :func:`pointer` iterator, this
1005+
will typically lead to infinite loops or crashes, because ctypes has no way
1006+
of knowing when to stop iteration. In other words, a ``pointer`` iterator
1007+
will infinitely yield arbitrary memory.
1008+
10001009
Behind the scenes, the :func:`pointer` function does more than simply create
10011010
pointer instances, it has to create pointer *types* first. This is done with the
10021011
:func:`POINTER` function, which accepts any :mod:`!ctypes` type, and returns a
@@ -3383,3 +3392,47 @@ Exceptions
33833392
.. availability:: Windows
33843393

33853394
.. versionadded:: 3.14
3395+
3396+
3397+
Library version
3398+
^^^^^^^^^^^^^^^
3399+
3400+
The following constants are only available if :mod:`!ctypes` was built with
3401+
libffi 3.5 or later, which is the first version providing this information.
3402+
3403+
.. data:: LIBFFI_VERSION
3404+
3405+
The version string of the libffi library that was used for building
3406+
the module, like ``'3.5.2'``.
3407+
This may be different from the libffi library actually used at runtime,
3408+
which is available as :const:`libffi_version`.
3409+
3410+
.. versionadded:: next
3411+
3412+
.. data:: libffi_version
3413+
3414+
The version string of the libffi library actually loaded by the interpreter.
3415+
3416+
.. versionadded:: next
3417+
3418+
.. data:: LIBFFI_VERSION_INFO
3419+
3420+
A named tuple containing the three components of the libffi library
3421+
version that was used for building the module:
3422+
*major*, *minor*, and *patch*.
3423+
All values are integers.
3424+
The components can also be accessed by name,
3425+
so ``ctypes.LIBFFI_VERSION_INFO[0]`` is equivalent to
3426+
``ctypes.LIBFFI_VERSION_INFO.major`` and so on.
3427+
This may be different from the libffi library actually used at runtime,
3428+
which is available as :const:`libffi_version_info`.
3429+
3430+
.. versionadded:: next
3431+
3432+
.. data:: libffi_version_info
3433+
3434+
A named tuple containing the version of the libffi library
3435+
actually loaded by the interpreter,
3436+
with the same fields as :const:`LIBFFI_VERSION_INFO`.
3437+
3438+
.. versionadded:: next

‎Doc/library/ipaddress.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ write code that handles both IP versions correctly. Address objects are
261261

262262
.. attribute:: ipv6_mapped
263263

264-
:class:`IPv4Address` object representing the IPv4-mapped IPv6 address. See :RFC:`4291`.
264+
:class:`IPv6Address` object representing the IPv4-mapped IPv6 address. See :RFC:`4291`.
265265

266266
.. versionadded:: 3.13
267267

‎Doc/library/json.rst‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,16 @@ Basic Usage
234234
If ``True``, dictionaries will be outputted sorted by key.
235235
Default ``False``.
236236

237+
.. note::
238+
239+
Keys in key/value pairs of JSON are always of the type :class:`str`. When
240+
a dictionary is converted into JSON, all the keys of the dictionary are
241+
converted to strings. As a result of this, if a dictionary is converted
242+
into JSON and then back into a dictionary, the dictionary may not equal
243+
the original one. That is, ``loads(dumps(x)) != x`` if x has non-string
244+
keys. *sort_keys* sorts the keys before they are converted to strings,
245+
so numeric keys are sorted by value, not by their string representation.
246+
237247
.. versionchanged:: 3.2
238248
Allow strings for *indent* in addition to integers.
239249

@@ -253,17 +263,6 @@ Basic Usage
253263
table <py-to-json-table>`. The arguments have the same meaning as in
254264
:func:`dump`.
255265

256-
.. note::
257-
258-
Keys in key/value pairs of JSON are always of the type :class:`str`. When
259-
a dictionary is converted into JSON, all the keys of the dictionary are
260-
coerced to strings. As a result of this, if a dictionary is converted
261-
into JSON and then back into a dictionary, the dictionary may not equal
262-
the original one. That is, ``loads(dumps(x)) != x`` if x has non-string
263-
keys.
264-
*sort_keys* sorts the keys before they are coerced to strings,
265-
so numeric keys are sorted by value, not by their string representation.
266-
267266
.. function:: load(fp, *, cls=None, object_hook=None, parse_float=None, \
268267
parse_int=None, parse_constant=None, \
269268
object_pairs_hook=None, array_hook=None, **kw)

‎Doc/library/statistics.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@ However, for reading convenience, most of the examples show sorted sequences.
306306
.. image:: kde_example.png
307307
:alt: Scatter plot of the estimated probability density function.
308308

309+
Because the returned ``f_hat`` function is typically called many times,
310+
it caches the *data* for performance. To support dynamic datasets, this
311+
cache automatically refreshes whenever the length of the *data* changes.
312+
This allows new samples to be added as they become available.
313+
309314
.. versionadded:: 3.13
310315

311316

0 commit comments

Comments
 (0)