Skip to content

Commit d5c1b1b

Browse files
committed
Merge branch 'main' into iterator_freelists
2 parents 7afbc35 + 2228e92 commit d5c1b1b

Some content is hidden

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

48 files changed

+2160
-806
lines changed

.github/workflows/reusable-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
100100
doctest:
101101
name: 'Doctest'
102-
runs-on: ubuntu-22.04
102+
runs-on: ubuntu-24.04
103103
timeout-minutes: 60
104104
steps:
105105
- uses: actions/checkout@v4

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ repos:
5555
hooks:
5656
- id: check-dependabot
5757
- id: check-github-workflows
58+
- id: check-readthedocs
5859

5960
- repo: https://github.com/rhysd/actionlint
6061
rev: v1.7.4

Doc/c-api/object.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,13 @@ Object Protocol
493493
on failure. This is equivalent to the Python statement ``del o[key]``.
494494
495495
496+
.. c:function:: int PyObject_DelItemString(PyObject *o, const char *key)
497+
498+
This is the same as :c:func:`PyObject_DelItem`, but *key* is
499+
specified as a :c:expr:`const char*` UTF-8 encoded bytes string,
500+
rather than a :c:expr:`PyObject*`.
501+
502+
496503
.. c:function:: PyObject* PyObject_Dir(PyObject *o)
497504
498505
This is equivalent to the Python expression ``dir(o)``, returning a (possibly

Doc/library/calendar.rst

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,46 +146,61 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
146146
the specified width, representing an empty day. The *weekday* parameter
147147
is unused.
148148

149-
.. method:: formatweek(theweek, w=0)
149+
.. method:: formatweek(theweek, w=0, highlight_day=None)
150150

151151
Return a single week in a string with no newline. If *w* is provided, it
152152
specifies the width of the date columns, which are centered. Depends
153153
on the first weekday as specified in the constructor or set by the
154154
:meth:`setfirstweekday` method.
155155

156+
.. versionchanged:: next
157+
If *highlight_day* is given, this date is highlighted in color.
158+
This can be :ref:`controlled using environment variables
159+
<using-on-controlling-color>`.
160+
161+
156162
.. method:: formatweekday(weekday, width)
157163

158164
Return a string representing the name of a single weekday formatted to
159165
the specified *width*. The *weekday* parameter is an integer representing
160166
the day of the week, where ``0`` is Monday and ``6`` is Sunday.
161167

168+
162169
.. method:: formatweekheader(width)
163170

164171
Return a string containing the header row of weekday names, formatted
165172
with the given *width* for each column. The names depend on the locale
166173
settings and are padded to the specified width.
167174

168-
.. method:: formatmonth(theyear, themonth, w=0, l=0)
175+
176+
.. method:: formatmonth(theyear, themonth, w=0, l=0, highlight_day=None)
169177

170178
Return a month's calendar in a multi-line string. If *w* is provided, it
171179
specifies the width of the date columns, which are centered. If *l* is
172180
given, it specifies the number of lines that each week will use. Depends
173181
on the first weekday as specified in the constructor or set by the
174182
:meth:`setfirstweekday` method.
175183

184+
.. versionchanged:: next
185+
If *highlight_day* is given, this date is highlighted in color.
186+
This can be :ref:`controlled using environment variables
187+
<using-on-controlling-color>`.
188+
189+
176190
.. method:: formatmonthname(theyear, themonth, width=0, withyear=True)
177191

178192
Return a string representing the month's name centered within the
179193
specified *width*. If *withyear* is ``True``, include the year in the
180194
output. The *theyear* and *themonth* parameters specify the year
181195
and month for the name to be formatted respectively.
182196

197+
183198
.. method:: prmonth(theyear, themonth, w=0, l=0)
184199

185200
Print a month's calendar as returned by :meth:`formatmonth`.
186201

187202

188-
.. method:: formatyear(theyear, w=2, l=1, c=6, m=3)
203+
.. method:: formatyear(theyear, w=2, l=1, c=6, m=3, highlight_day=None)
189204

190205
Return a *m*-column calendar for an entire year as a multi-line string.
191206
Optional parameters *w*, *l*, and *c* are for date column width, lines per
@@ -194,6 +209,11 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
194209
:meth:`setfirstweekday` method. The earliest year for which a calendar
195210
can be generated is platform-dependent.
196211

212+
.. versionchanged:: next
213+
If *highlight_day* is given, this date is highlighted in color.
214+
This can be :ref:`controlled using environment variables
215+
<using-on-controlling-color>`.
216+
197217

198218
.. method:: pryear(theyear, w=2, l=1, c=6, m=3)
199219

@@ -549,7 +569,7 @@ The :mod:`calendar` module defines the following exceptions:
549569

550570
.. _calendar-cli:
551571

552-
Command-Line Usage
572+
Command-line usage
553573
------------------
554574

555575
.. versionadded:: 2.5
@@ -687,6 +707,9 @@ The following options are accepted:
687707
The number of months printed per row.
688708
Defaults to 3.
689709

710+
.. versionchanged:: next
711+
By default, today's date is highlighted in color and can be
712+
:ref:`controlled using environment variables <using-on-controlling-color>`.
690713

691714
*HTML-mode options:*
692715

Doc/library/ctypes.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,6 +2182,28 @@ Utility functions
21822182
.. audit-event:: ctypes.wstring_at ptr,size ctypes.wstring_at
21832183

21842184

2185+
.. function:: memoryview_at(ptr, size, readonly=False)
2186+
2187+
Return a :class:`memoryview` object of length *size* that references memory
2188+
starting at *void \*ptr*.
2189+
2190+
If *readonly* is true, the returned :class:`!memoryview` object can
2191+
not be used to modify the underlying memory.
2192+
(Changes made by other means will still be reflected in the returned
2193+
object.)
2194+
2195+
This function is similar to :func:`string_at` with the key
2196+
difference of not making a copy of the specified memory.
2197+
It is a semantically equivalent (but more efficient) alternative to
2198+
``memoryview((c_byte * size).from_address(ptr))``.
2199+
(While :meth:`~_CData.from_address` only takes integers, *ptr* can also
2200+
be given as a :class:`ctypes.POINTER` or a :func:`~ctypes.byref` object.)
2201+
2202+
.. audit-event:: ctypes.memoryview_at address,size,readonly
2203+
2204+
.. versionadded:: next
2205+
2206+
21852207
.. _ctypes-data-types:
21862208

21872209
Data types

Doc/library/faulthandler.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ Fault handler state
9191
The dump now mentions if a garbage collector collection is running
9292
if *all_threads* is true.
9393

94+
.. versionchanged:: next
95+
Only the current thread is dumped if the :term:`GIL` is disabled to
96+
prevent the risk of data races.
97+
9498
.. function:: disable()
9599

96100
Disable the fault handler: uninstall the signal handlers installed by

Doc/library/json.rst

Lines changed: 74 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -151,69 +151,94 @@ Basic Usage
151151
sort_keys=False, **kw)
152152
153153
Serialize *obj* as a JSON formatted stream to *fp* (a ``.write()``-supporting
154-
:term:`file-like object`) using this :ref:`conversion table
154+
:term:`file-like object`) using this :ref:`Python-to-JSON conversion table
155155
<py-to-json-table>`.
156156

157-
If *skipkeys* is true (default: ``False``), then dict keys that are not
158-
of a basic type (:class:`str`, :class:`int`, :class:`float`, :class:`bool`,
159-
``None``) will be skipped instead of raising a :exc:`TypeError`.
160-
161-
The :mod:`json` module always produces :class:`str` objects, not
162-
:class:`bytes` objects. Therefore, ``fp.write()`` must support :class:`str`
163-
input.
164-
165-
If *ensure_ascii* is true (the default), the output is guaranteed to
166-
have all incoming non-ASCII characters escaped. If *ensure_ascii* is
167-
false, these characters will be output as-is.
168-
169-
If *check_circular* is false (default: ``True``), then the circular
170-
reference check for container types will be skipped and a circular reference
171-
will result in a :exc:`RecursionError` (or worse).
157+
.. note::
172158

173-
If *allow_nan* is false (default: ``True``), then it will be a
174-
:exc:`ValueError` to serialize out of range :class:`float` values (``nan``,
175-
``inf``, ``-inf``) in strict compliance of the JSON specification.
176-
If *allow_nan* is true, their JavaScript equivalents (``NaN``,
177-
``Infinity``, ``-Infinity``) will be used.
159+
Unlike :mod:`pickle` and :mod:`marshal`, JSON is not a framed protocol,
160+
so trying to serialize multiple objects with repeated calls to
161+
:func:`dump` using the same *fp* will result in an invalid JSON file.
178162

179-
If *indent* is a non-negative integer or string, then JSON array elements and
180-
object members will be pretty-printed with that indent level. An indent level
181-
of 0, negative, or ``""`` will only insert newlines. ``None`` (the default)
182-
selects the most compact representation. Using a positive integer indent
183-
indents that many spaces per level. If *indent* is a string (such as ``"\t"``),
184-
that string is used to indent each level.
163+
:param object obj:
164+
The Python object to be serialized.
165+
166+
:param fp:
167+
The file-like object *obj* will be serialized to.
168+
The :mod:`!json` module always produces :class:`str` objects,
169+
not :class:`bytes` objects,
170+
therefore ``fp.write()`` must support :class:`str` input.
171+
:type fp: :term:`file-like object`
172+
173+
:param bool skipkeys:
174+
If ``True``, keys that are not of a basic type
175+
(:class:`str`, :class:`int`, :class:`float`, :class:`bool`, ``None``)
176+
will be skipped instead of raising a :exc:`TypeError`.
177+
Default ``False``.
178+
179+
:param bool ensure_ascii:
180+
If ``True`` (the default), the output is guaranteed to
181+
have all incoming non-ASCII characters escaped.
182+
If ``False``, these characters will be outputted as-is.
183+
184+
:param bool check_circular:
185+
If ``False``, the circular reference check for container types is skipped
186+
and a circular reference will result in a :exc:`RecursionError` (or worse).
187+
Default ``True``.
188+
189+
:param bool allow_nan:
190+
If ``False``, serialization of out-of-range :class:`float` values
191+
(``nan``, ``inf``, ``-inf``) will result in a :exc:`ValueError`,
192+
in strict compliance with the JSON specification.
193+
If ``True`` (the default), their JavaScript equivalents
194+
(``NaN``, ``Infinity``, ``-Infinity``) are used.
195+
196+
:param cls:
197+
If set, a custom JSON encoder with the
198+
:meth:`~JSONEncoder.default` method overridden,
199+
for serializing into custom datatypes.
200+
If ``None`` (the default), :class:`!JSONEncoder` is used.
201+
:type cls: a :class:`JSONEncoder` subclass
202+
203+
:param indent:
204+
If a positive integer or string, JSON array elements and
205+
object members will be pretty-printed with that indent level.
206+
A positive integer indents that many spaces per level;
207+
a string (such as ``"\t"``) is used to indent each level.
208+
If zero, negative, or ``""`` (the empty string),
209+
only newlines are inserted.
210+
If ``None`` (the default), the most compact representation is used.
211+
:type indent: int | str | None
212+
213+
:param separators:
214+
A two-tuple: ``(item_separator, key_separator)``.
215+
If ``None`` (the default), *separators* defaults to
216+
``(', ', ': ')`` if *indent* is ``None``,
217+
and ``(',', ': ')`` otherwise.
218+
For the most compact JSON,
219+
specify ``(',', ':')`` to eliminate whitespace.
220+
:type separators: tuple | None
221+
222+
:param default:
223+
A function that is called for objects that can't otherwise be serialized.
224+
It should return a JSON encodable version of the object
225+
or raise a :exc:`TypeError`.
226+
If ``None`` (the default), :exc:`!TypeError` is raised.
227+
:type default: :term:`callable` | None
228+
229+
:param bool sort_keys:
230+
If ``True``, dictionaries will be outputted sorted by key.
231+
Default ``False``.
185232

186233
.. versionchanged:: 3.2
187234
Allow strings for *indent* in addition to integers.
188235

189-
If specified, *separators* should be an ``(item_separator, key_separator)``
190-
tuple. The default is ``(', ', ': ')`` if *indent* is ``None`` and
191-
``(',', ': ')`` otherwise. To get the most compact JSON representation,
192-
you should specify ``(',', ':')`` to eliminate whitespace.
193-
194236
.. versionchanged:: 3.4
195237
Use ``(',', ': ')`` as default if *indent* is not ``None``.
196238

197-
If specified, *default* should be a function that gets called for objects that
198-
can't otherwise be serialized. It should return a JSON encodable version of
199-
the object or raise a :exc:`TypeError`. If not specified, :exc:`TypeError`
200-
is raised.
201-
202-
If *sort_keys* is true (default: ``False``), then the output of
203-
dictionaries will be sorted by key.
204-
205-
To use a custom :class:`JSONEncoder` subclass (e.g. one that overrides the
206-
:meth:`~JSONEncoder.default` method to serialize additional types), specify it with the
207-
*cls* kwarg; otherwise :class:`JSONEncoder` is used.
208-
209239
.. versionchanged:: 3.6
210240
All optional parameters are now :ref:`keyword-only <keyword-only_parameter>`.
211241

212-
.. note::
213-
214-
Unlike :mod:`pickle` and :mod:`marshal`, JSON is not a framed protocol,
215-
so trying to serialize multiple objects with repeated calls to
216-
:func:`dump` using the same *fp* will result in an invalid JSON file.
217242

218243
.. function:: dumps(obj, *, skipkeys=False, ensure_ascii=True, \
219244
check_circular=True, allow_nan=True, cls=None, \

Doc/library/math.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ Floating point arithmetic
248248

249249
.. function:: fmod(x, y)
250250

251-
Return ``fmod(x, y)``, as defined by the platform C library. Note that the
251+
Return the floating-point remainder of ``x / y``,
252+
as defined by the platform C library function ``fmod(x, y)``. Note that the
252253
Python expression ``x % y`` may not return the same result. The intent of the C
253254
standard is that ``fmod(x, y)`` be exactly (mathematically; to infinite
254255
precision) equal to ``x - n*y`` for some integer *n* such that the result has

Doc/using/configure.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Features and minimum versions required to build CPython:
2929

3030
* Tcl/Tk 8.5.12 for the :mod:`tkinter` module.
3131

32-
* Autoconf 2.71 and aclocal 1.16.5 are required to regenerate the
32+
* Autoconf 2.72 and aclocal 1.16.5 are required to regenerate the
3333
:file:`configure` script.
3434

3535
.. versionchanged:: 3.1
@@ -58,6 +58,9 @@ Features and minimum versions required to build CPython:
5858
.. versionchanged:: 3.13
5959
Autoconf 2.71, aclocal 1.16.5 and SQLite 3.15.2 are now required.
6060

61+
.. versionchanged:: next
62+
Autoconf 2.72 is now required.
63+
6164
See also :pep:`7` "Style Guide for C Code" and :pep:`11` "CPython platform
6265
support".
6366

Doc/whatsnew/3.14.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,19 @@ ast
296296
* The ``repr()`` output for AST nodes now includes more information.
297297
(Contributed by Tomas R in :gh:`116022`.)
298298

299+
300+
calendar
301+
--------
302+
303+
* By default, today's date is highlighted in color in :mod:`calendar`'s
304+
:ref:`command-line <calendar-cli>` text output.
305+
This can be controlled via the :envvar:`PYTHON_COLORS` environment
306+
variable as well as the canonical |NO_COLOR|_
307+
and |FORCE_COLOR|_ environment variables.
308+
See also :ref:`using-on-controlling-color`.
309+
(Contributed by Hugo van Kemenade in :gh:`128317`.)
310+
311+
299312
concurrent.futures
300313
------------------
301314

@@ -330,6 +343,14 @@ ctypes
330343
* On Windows, the :func:`~ctypes.CopyComPointer` function is now public.
331344
(Contributed by Jun Komoda in :gh:`127275`.)
332345

346+
* :func:`ctypes.memoryview_at` now exists to create a
347+
:class:`memoryview` object that refers to the supplied pointer and
348+
length. This works like :func:`ctypes.string_at` except it avoids a
349+
buffer copy, and is typically useful when implementing pure Python
350+
callback functions that are passed dynamically-sized buffers.
351+
(Contributed by Rian Hunter in :gh:`112018`.)
352+
353+
333354
datetime
334355
--------
335356

0 commit comments

Comments
 (0)