Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef9dd50

Browse files
authored
Merge branch 'main' into buffered-gzip-writes
2 parents bc4d929 + b400219 commit ef9dd50

58 files changed

Lines changed: 2580 additions & 902 deletions

Some content is hidden

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

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# GitHub
88
.github/** @ezio-melotti
99

10+
# Build system
11+
configure* @erlend-aasland @corona10
12+
1013
# asyncio
1114
**/*asyncio* @1st1 @asvetlov @gvanrossum @kumaraditya303
1215

Doc/c-api/long.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
9494
ignored. If there are no digits or *str* is not NULL-terminated following the
9595
digits and trailing whitespace, :exc:`ValueError` will be raised.
9696
97+
.. seealso:: Python methods :meth:`int.to_bytes` and :meth:`int.from_bytes`
98+
to convert a :c:type:`PyLongObject` to/from an array of bytes in base
99+
``256``. You can call those from C using :c:func:`PyObject_CallMethod`.
100+
97101
98102
.. c:function:: PyObject* PyLong_FromUnicodeObject(PyObject *u, int base)
99103

Doc/library/asyncio.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ Additionally, there are **low-level** APIs for
5656
* :ref:`bridge <asyncio-futures>` callback-based libraries and code
5757
with async/await syntax.
5858

59+
You can experiment with an ``asyncio`` concurrent context in the REPL:
60+
61+
.. code-block:: pycon
62+
63+
$ python -m asyncio
64+
asyncio REPL ...
65+
Use "await" directly instead of "asyncio.run()".
66+
Type "help", "copyright", "credits" or "license" for more information.
67+
>>> import asyncio
68+
>>> await asyncio.sleep(10, result='hello')
69+
'hello'
70+
5971
.. include:: ../includes/wasm-notavail.rst
6072

6173
.. We use the "rubric" directive here to avoid creating

Doc/library/dis.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,10 @@ iterations of the loop.
700700
Yields ``STACK.pop()`` from a :term:`generator`.
701701

702702
.. versionchanged:: 3.11
703-
oparg set to be the stack depth, for efficient handling on frames.
703+
oparg set to be the stack depth.
704+
705+
.. versionchanged:: 3.12
706+
oparg set to be the exception block depth, for efficient closing of generators.
704707

705708

706709
.. opcode:: SETUP_ANNOTATIONS

Doc/library/fractions.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ another rational number, or from a string.
101101
.. versionchanged:: 3.12
102102
Space is allowed around the slash for string inputs: ``Fraction('2 / 3')``.
103103

104+
.. versionchanged:: 3.12
105+
:class:`Fraction` instances now support float-style formatting, with
106+
presentation types ``"e"``, ``"E"``, ``"f"``, ``"F"``, ``"g"``, ``"G"``
107+
and ``"%""``.
108+
104109
.. attribute:: numerator
105110

106111
Numerator of the Fraction in lowest term.
@@ -193,6 +198,29 @@ another rational number, or from a string.
193198
``ndigits`` is negative), again rounding half toward even. This
194199
method can also be accessed through the :func:`round` function.
195200

201+
.. method:: __format__(format_spec, /)
202+
203+
Provides support for float-style formatting of :class:`Fraction`
204+
instances via the :meth:`str.format` method, the :func:`format` built-in
205+
function, or :ref:`Formatted string literals <f-strings>`. The
206+
presentation types ``"e"``, ``"E"``, ``"f"``, ``"F"``, ``"g"``, ``"G"``
207+
and ``"%"`` are supported. For these presentation types, formatting for a
208+
:class:`Fraction` object ``x`` follows the rules outlined for
209+
the :class:`float` type in the :ref:`formatspec` section.
210+
211+
Here are some examples::
212+
213+
>>> from fractions import Fraction
214+
>>> format(Fraction(1, 7), '.40g')
215+
'0.1428571428571428571428571428571428571429'
216+
>>> format(Fraction('1234567.855'), '_.2f')
217+
'1_234_567.86'
218+
>>> f"{Fraction(355, 113):*>20.6e}"
219+
'********3.141593e+00'
220+
>>> old_price, new_price = 499, 672
221+
>>> "{:.2%} price increase".format(Fraction(new_price, old_price) - 1)
222+
'34.67% price increase'
223+
196224

197225
.. seealso::
198226

Doc/library/random.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ lognormal, negative exponential, gamma, and beta distributions. For generating
2121
distributions of angles, the von Mises distribution is available.
2222

2323
Almost all module functions depend on the basic function :func:`.random`, which
24-
generates a random float uniformly in the semi-open range [0.0, 1.0). Python
25-
uses the Mersenne Twister as the core generator. It produces 53-bit precision
24+
generates a random float uniformly in the half-open range ``0.0 <= X < 1.0``.
25+
Python uses the Mersenne Twister as the core generator. It produces 53-bit precision
2626
floats and has a period of 2\*\*19937-1. The underlying implementation in C is
2727
both fast and threadsafe. The Mersenne Twister is one of the most extensively
2828
tested random number generators in existence. However, being completely
@@ -294,7 +294,7 @@ be found in any statistics text.
294294

295295
.. function:: random()
296296

297-
Return the next random floating point number in the range [0.0, 1.0).
297+
Return the next random floating point number in the range ``0.0 <= X < 1.0``
298298

299299

300300
.. function:: uniform(a, b)

Doc/library/uuid.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ The :mod:`uuid` module can be executed as a script from the command line.
272272

273273
.. code-block:: sh
274274
275-
python -m uuid [-h] [-u {uuid1,uuid3,uuid4,uuid5}] [-ns NAMESPACE] [-n NAME]
275+
python -m uuid [-h] [-u {uuid1,uuid3,uuid4,uuid5}] [-n NAMESPACE] [-N NAME]
276276
277277
The following options are accepted:
278278

@@ -288,13 +288,14 @@ The following options are accepted:
288288
Specify the function name to use to generate the uuid. By default :func:`uuid4`
289289
is used.
290290

291-
.. cmdoption:: -ns <namespace>
291+
.. cmdoption:: -n <namespace>
292292
--namespace <namespace>
293293

294-
The namespace used as part of generating the uuid. Only required for
295-
:func:`uuid3` / :func:`uuid5` functions.
294+
The namespace is a ``UUID``, or ``@ns`` where ``ns`` is a well-known predefined UUID
295+
addressed by namespace name. Such as ``@dns``, ``@url``, ``@oid``, and ``@x500``.
296+
Only required for :func:`uuid3` / :func:`uuid5` functions.
296297

297-
.. cmdoption:: -n <name>
298+
.. cmdoption:: -N <name>
298299
--name <name>
299300

300301
The name used as part of generating the uuid. Only required for
@@ -351,12 +352,12 @@ Here are some examples of typical usage of the :mod:`uuid` command line interfac
351352

352353
.. code-block:: shell
353354
354-
# generate a random uuid - by default uuid4() is used
355-
$ python -m uuid
355+
# generate a random uuid - by default uuid4() is used
356+
$ python -m uuid
356357
357-
# generate a uuid using uuid1()
358-
$ python -m uuid -u uuid1
358+
# generate a uuid using uuid1()
359+
$ python -m uuid -u uuid1
359360
360-
# generate a uuid using uuid5
361-
$ python -m uuid -u uuid5 -ns NAMESPACE_URL -n example.com
361+
# generate a uuid using uuid5
362+
$ python -m uuid -u uuid5 -n @url -N example.com
362363

Doc/library/xml.etree.elementtree.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,9 +1045,9 @@ Element Objects
10451045
:meth:`~object.__getitem__`, :meth:`~object.__setitem__`,
10461046
:meth:`~object.__len__`.
10471047

1048-
Caution: Elements with no subelements will test as ``False``. This behavior
1049-
will change in future versions. Use specific ``len(elem)`` or ``elem is
1050-
None`` test instead. ::
1048+
Caution: Elements with no subelements will test as ``False``. Testing the
1049+
truth value of an Element is deprecated and will raise an exception in
1050+
Python 3.14. Use specific ``len(elem)`` or ``elem is None`` test instead.::
10511051

10521052
element = root.find('foo')
10531053

@@ -1057,6 +1057,9 @@ Element Objects
10571057
if element is None:
10581058
print("element not found")
10591059

1060+
.. versionchanged:: 3.12
1061+
Testing the truth value of an Element emits :exc:`DeprecationWarning`.
1062+
10601063
Prior to Python 3.8, the serialisation order of the XML attributes of
10611064
elements was artificially made predictable by sorting the attributes by
10621065
their name. Based on the now guaranteed ordering of dicts, this arbitrary

Doc/whatsnew/3.12.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ dis
269269
:data:`~dis.hasarg` collection instead.
270270
(Contributed by Irit Katriel in :gh:`94216`.)
271271

272+
fractions
273+
---------
274+
275+
* Objects of type :class:`fractions.Fraction` now support float-style
276+
formatting. (Contributed by Mark Dickinson in :gh:`100161`.)
277+
272278
math
273279
----
274280

@@ -419,6 +425,16 @@ Deprecated
419425
is no current event loop set and it decides to create one.
420426
(Contributed by Serhiy Storchaka and Guido van Rossum in :gh:`100160`.)
421427

428+
* The :mod:`xml.etree.ElementTree` module now emits :exc:`DeprecationWarning`
429+
when testing the truth value of an :class:`xml.etree.ElementTree.Element`.
430+
Before, the Python implementation emitted :exc:`FutureWarning`, and the C
431+
implementation emitted nothing.
432+
433+
* In accordance with :pep:`699`, the ``ma_version_tag`` field in :c:type:`PyDictObject`
434+
is deprecated for extension modules. Accessing this field will generate a compiler
435+
warning at compile time. This field will be removed in Python 3.14.
436+
(Contributed by Ramvikrams and Kumar Aditya in :gh:`101193`. PEP by Ken Jin.)
437+
422438

423439
Pending Removal in Python 3.13
424440
------------------------------
@@ -481,6 +497,9 @@ Pending Removal in Python 3.14
481497
* ``__package__`` and ``__cached__`` will cease to be set or taken
482498
into consideration by the import system (:gh:`97879`).
483499

500+
* Testing the truth value of an :class:`xml.etree.ElementTree.Element`
501+
is deprecated and will raise an exception in Python 3.14.
502+
484503

485504
Pending Removal in Future Versions
486505
----------------------------------

Include/cpython/dictobject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ typedef struct {
1616

1717
/* Dictionary version: globally unique, value change each time
1818
the dictionary is modified */
19+
#ifdef Py_BUILD_CORE
1920
uint64_t ma_version_tag;
21+
#else
22+
Py_DEPRECATED(3.12) uint64_t ma_version_tag;
23+
#endif
2024

2125
PyDictKeysObject *ma_keys;
2226

0 commit comments

Comments
 (0)