Skip to content

Commit 15c2604

Browse files
committed
Merge branch 'main' into gh-120321-gen-atomic
2 parents 46a8e84 + 16a305f commit 15c2604

File tree

213 files changed

+6204
-4737
lines changed

Some content is hidden

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

213 files changed

+6204
-4737
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,10 @@ Tools/jit/ @brandtbucher @savannahostrowski @diegorusso
289289
InternalDocs/jit.md @brandtbucher @savannahostrowski @diegorusso @AA-Turner
290290

291291
# Micro-op / μop / Tier 2 Optimiser
292-
Python/optimizer.c @markshannon
292+
Python/optimizer.c @markshannon @Fidget-Spinner
293293
Python/optimizer_analysis.c @markshannon @tomasr8 @Fidget-Spinner
294294
Python/optimizer_bytecodes.c @markshannon @tomasr8 @Fidget-Spinner
295-
Python/optimizer_symbols.c @markshannon @tomasr8
295+
Python/optimizer_symbols.c @markshannon @tomasr8 @Fidget-Spinner
296296

297297
# Parser, Lexer, and Grammar
298298
Grammar/python.gram @pablogsal @lysnikolaou

Doc/c-api/extension-modules.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ and must be named after the module name plus an extension listed in
2929
Extension export hook
3030
.....................
3131

32-
.. versionadded:: next
32+
.. versionadded:: 3.15
3333

3434
Support for the :samp:`PyModExport_{<name>}` export hook was added in Python
3535
3.15. The older way of defining modules is still available: consult either
@@ -191,7 +191,7 @@ the :c:data:`Py_mod_multiple_interpreters` slot.
191191
``PyInit`` function
192192
...................
193193

194-
.. deprecated:: next
194+
.. deprecated:: 3.15
195195

196196
This functionality is :term:`soft deprecated`.
197197
It will not get new features, but there are no plans to remove it.
@@ -272,7 +272,7 @@ For example, a module called ``spam`` would be defined like this::
272272
Legacy single-phase initialization
273273
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
274274
275-
.. deprecated:: next
275+
.. deprecated:: 3.15
276276
277277
Single-phase initialization is :term:`soft deprecated`.
278278
It is a legacy mechanism to initialize extension

Doc/c-api/module.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Modules created using the C API are typically defined using an
142142
array of :dfn:`slots`.
143143
The slots provide a "description" of how a module should be created.
144144
145-
.. versionchanged:: next
145+
.. versionchanged:: 3.15
146146
147147
Previously, a :c:type:`PyModuleDef` struct was necessary to define modules.
148148
The older way of defining modules is still available: consult either the
@@ -190,7 +190,7 @@ Metadata slots
190190
However, it is still recommended to include this slot for introspection
191191
and debugging purposes.
192192
193-
.. versionadded:: next
193+
.. versionadded:: 3.15
194194
195195
Use :c:member:`PyModuleDef.m_name` instead to support previous versions.
196196
@@ -201,7 +201,7 @@ Metadata slots
201201
202202
Usually it is set to a variable created with :c:macro:`PyDoc_STRVAR`.
203203
204-
.. versionadded:: next
204+
.. versionadded:: 3.15
205205
206206
Use :c:member:`PyModuleDef.m_doc` instead to support previous versions.
207207
@@ -332,7 +332,7 @@ Creation and initialization slots
332332
333333
.. versionadded:: 3.5
334334
335-
.. versionchanged:: next
335+
.. versionchanged:: 3.15
336336
337337
The *slots* argument may be a ``ModuleSpec``-like object, rather than
338338
a true :py:class:`~importlib.machinery.ModuleSpec` instance.
@@ -365,7 +365,7 @@ Creation and initialization slots
365365
366366
.. versionadded:: 3.5
367367
368-
.. versionchanged:: next
368+
.. versionchanged:: 3.15
369369
370370
Repeated ``Py_mod_exec`` slots are disallowed, except in
371371
:c:type:`PyModuleDef.m_slots`.
@@ -384,7 +384,7 @@ Creation and initialization slots
384384
The table must be statically allocated (or otherwise guaranteed to outlive
385385
the module object).
386386
387-
.. versionadded:: next
387+
.. versionadded:: 3.15
388388
389389
Use :c:member:`PyModuleDef.m_methods` instead to support previous versions.
390390
@@ -434,7 +434,7 @@ To retrieve the state from a given module, use the following functions:
434434
435435
On error, set *\*result* to -1, and return -1 with an exception set.
436436
437-
.. versionadded:: next
437+
.. versionadded:: 3.15
438438
439439
440440
@@ -459,7 +459,7 @@ defining the module state.
459459
460460
Use :c:func:`PyModule_GetStateSize` to retrieve the size of a given module.
461461
462-
.. versionadded:: next
462+
.. versionadded:: 3.15
463463
464464
Use :c:member:`PyModuleDef.m_size` instead to support previous versions.
465465
@@ -482,7 +482,7 @@ defining the module state.
482482
(:c:data:`Py_mod_state_size`) is greater than 0 and the module state
483483
(as returned by :c:func:`PyModule_GetState`) is ``NULL``.
484484
485-
.. versionadded:: next
485+
.. versionadded:: 3.15
486486
487487
Use :c:member:`PyModuleDef.m_size` instead to support previous versions.
488488
@@ -510,7 +510,7 @@ defining the module state.
510510
the cyclic garbage collector is not involved and
511511
the :c:macro:`Py_mod_state_free` function is called directly.
512512
513-
.. versionadded:: next
513+
.. versionadded:: 3.15
514514
515515
Use :c:member:`PyModuleDef.m_clear` instead to support previous versions.
516516
@@ -532,7 +532,7 @@ defining the module state.
532532
(:c:data:`Py_mod_state_size`) is greater than 0 and the module state
533533
(as returned by :c:func:`PyModule_GetState`) is ``NULL``.
534534
535-
.. versionadded:: next
535+
.. versionadded:: 3.15
536536
537537
Use :c:member:`PyModuleDef.m_free` instead to support previous versions.
538538
@@ -593,15 +593,15 @@ A module's token -- and the *your_token* value to use in the above code -- is:
593593
This means that :c:macro:`!Py_mod_token` cannot be used in
594594
:c:member:`PyModuleDef.m_slots`.
595595
596-
.. versionadded:: next
596+
.. versionadded:: 3.15
597597
598598
.. c:function:: int PyModule_GetToken(PyObject *module, void** result)
599599
600600
Set *\*result* to the module's token and return 0.
601601
602602
On error, set *\*result* to NULL, and return -1 with an exception set.
603603
604-
.. versionadded:: next
604+
.. versionadded:: 3.15
605605
606606
See also :c:func:`PyType_GetModuleByToken`.
607607
@@ -641,7 +641,7 @@ rather than from an extension's :ref:`export hook <extension-export-hook>`.
641641
:c:func:`!PyModule_FromSlotsAndSpec` call.
642642
In particular, it may be heap-allocated.
643643
644-
.. versionadded:: next
644+
.. versionadded:: 3.15
645645
646646
.. c:function:: int PyModule_Exec(PyObject *module)
647647
@@ -654,7 +654,7 @@ rather than from an extension's :ref:`export hook <extension-export-hook>`.
654654
:ref:`legacy single-phase initialization <single-phase-initialization>`,
655655
this function does nothing and returns 0.
656656
657-
.. versionadded:: next
657+
.. versionadded:: 3.15
658658
659659
660660

Doc/c-api/object.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Object Protocol
111111
object type name: str
112112
object repr : 'abcdef'
113113
114-
.. versionadded:: next
114+
.. versionadded:: 3.15
115115
116116
117117
.. c:function:: int PyObject_HasAttrWithError(PyObject *o, PyObject *attr_name)

Doc/c-api/tuple.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,11 @@ Tuple Objects
148148
Struct Sequence Objects
149149
-----------------------
150150
151-
Struct sequence objects are the C equivalent of :func:`~collections.namedtuple`
152-
objects, i.e. a sequence whose items can also be accessed through attributes.
151+
A struct sequence object is a :term:`named tuple`, that is, a sequence
152+
whose items can also be accessed through attributes.
153+
It is similar to :func:`collections.namedtuple`, but provides a slightly
154+
different interface.
155+
153156
To create a struct sequence, you first have to create a specific struct sequence
154157
type.
155158

Doc/c-api/type.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ Type Objects
317317
and other places where a method's defining class cannot be passed using the
318318
:c:type:`PyCMethod` calling convention.
319319
320-
.. versionadded:: next
320+
.. versionadded:: 3.15
321321
322322
323323
.. c:function:: PyObject* PyType_GetModuleByDef(PyTypeObject *type, struct PyModuleDef *def)

Doc/deprecations/pending-removal-in-3.20.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Pending removal in Python 3.20
2323
- :mod:`tabnanny`
2424
- :mod:`tkinter.font`
2525
- :mod:`tkinter.ttk`
26+
- :mod:`wsgiref.simple_server`
2627
- :mod:`zlib`
2728

2829
(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)

Doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ Glossary
813813
:func:`itertools.groupby`.
814814

815815
There are several ways to create a key function. For example. the
816-
:meth:`str.lower` method can serve as a key function for case insensitive
816+
:meth:`str.casefold` method can serve as a key function for case insensitive
817817
sorts. Alternatively, a key function can be built from a
818818
:keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also,
819819
:func:`operator.attrgetter`, :func:`operator.itemgetter`, and

Doc/library/argparse.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ behavior::
13701370
>>> parser.parse_args('--foo XXX'.split())
13711371
Namespace(bar='XXX')
13721372

1373-
.. versionchanged:: next
1373+
.. versionchanged:: 3.15
13741374
Single-dash long option now takes precedence over short options.
13751375

13761376

@@ -1473,7 +1473,7 @@ this API may be passed as the ``action`` parameter to
14731473

14741474
.. versionadded:: 3.9
14751475

1476-
.. versionchanged:: next
1476+
.. versionchanged:: 3.15
14771477
Added support for single-dash options.
14781478

14791479
Added support for alternate prefix_chars_.

Doc/library/decimal.rst

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ The :mod:`decimal` module provides support for fast correctly rounded
3434
decimal floating-point arithmetic. It offers several advantages over the
3535
:class:`float` datatype:
3636

37-
* Decimal "is based on a floating-point model which was designed with people
38-
in mind, and necessarily has a paramount guiding principle -- computers must
39-
provide an arithmetic that works in the same way as the arithmetic that
40-
people learn at school." -- excerpt from the decimal arithmetic specification.
37+
* Decimal "is based on a `floating-point model
38+
<https://speleotrove.com/decimal/damodel.html#refnumber>`__ which was designed
39+
with people in mind, and necessarily has a paramount guiding principle --
40+
computers must provide an arithmetic that works in the same way as the
41+
arithmetic that people learn at school." -- excerpt from the decimal
42+
arithmetic specification.
4143

4244
* Decimal numbers can be represented exactly. In contrast, numbers like
4345
``1.1`` and ``2.2`` do not have exact representations in binary
@@ -238,6 +240,26 @@ floating-point flying circus:
238240
>>> c % a
239241
Decimal('0.77')
240242

243+
Decimals can be formatted (with :func:`format` built-in or :ref:`f-strings`) in
244+
fixed-point or scientific notation, using the same formatting syntax (see
245+
:ref:`formatspec`) as builtin :class:`float` type:
246+
247+
.. doctest::
248+
249+
>>> format(Decimal('2.675'), "f")
250+
'2.675'
251+
>>> format(Decimal('2.675'), ".2f")
252+
'2.68'
253+
>>> f"{Decimal('2.675'):.2f}"
254+
'2.68'
255+
>>> format(Decimal('2.675'), ".2e")
256+
'2.68e+0'
257+
>>> with localcontext() as ctx:
258+
... ctx.rounding = ROUND_DOWN
259+
... print(format(Decimal('2.675'), ".2f"))
260+
...
261+
2.67
262+
241263
And some mathematical functions are also available to Decimal:
242264

243265
>>> getcontext().prec = 28

0 commit comments

Comments
 (0)