8000 Merge branch 'main' into fix-issue-126400 · python/cpython@bffa2ed · GitHub
[go: up one dir, main page]

Skip to content

Commit bffa2ed

Browse files
authored
Merge branch 'main' into fix-issue-126400
2 parents d72c357 + 29b5323 commit bffa2ed

File tree

117 files changed

+1195
-346
lines changed

Some content is hidden

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

117 files changed

+1195
-346
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
# Check for changes in regenerated files
7777
if test -n "$changes"; then
7878
echo "Generated files not up to date."
79-
echo "Perhaps you forgot to run make regen-all or build.bat --regen. ;)"
79+
echo "Perhaps you forgot to run make regen-configure ;)"
8080
echo "configure files must be regenerated with a specific version of autoconf."
8181
echo "$changes"
8282
echo ""

Doc/c-api/long.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,39 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
582582
.. versionadded:: 3.14
583583
584584
585+
.. c:function:: int PyLong_IsPositive(PyObject *obj)
586+
587+
Check if the integer object *obj* is positive (``obj > 0``).
588+
589+
If *obj* is an instance of :c:type:`PyLongObject` or its subtype,
590+
return ``1`` when it's positive and ``0`` otherwise. Else set an
591+
exception and return ``-1``.
592+
593+
.. versionadded:: next
594+
595+
596+
.. c:function:: int PyLong_IsNegative(PyObject *obj)
597+
598+
Check if the integer object *obj* is negative (``obj < 0``).
599+
600+
If *obj* is an instance of :c:type:`PyLongObject` or its subtype,
601+
return ``1`` when it's negative and ``0`` otherwise. Else set an
602+
exception and return ``-1``.
603+
604+
.. versionadded:: next
605+
606+
607+
.. c:function:: int PyLong_IsZero(PyObject *obj)
608+
609+
Check if the integer object *obj* is zero.
610+
611+
If *obj* is an instance of :c:type:`PyLongObject` or its subtype,
612+
return ``1`` when it's zero and ``0`` otherwise. Else set an
613+
exception and return ``-1``.
614+
615+
.. versionadded:: next
616+
617+
585618
.. c:function:: PyObject* PyLong_GetInfo(void)
586619
587620
On success, return a read only :term:`named tuple`, that holds

Doc/conf.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@
6767

6868
# General substitutions.
6969
project = 'Python'
70-
if sphinx.version_info[:2] >= (8, 1):
71-
copyright = "2001-%Y, Python Software Foundation"
72-
else:
73-
copyright = f"2001-{time.strftime('%Y')}, Python Software Foundation"
70+
copyright = "2001 Python Software Foundation"
7471

7572
# We look for the Include/patchlevel.h file in the current Python source tree
7673
# and replace the values accordingly.

Doc/copyright.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Copyright
44

55
Python and this documentation is:
66

7-
Copyright © 2001-2024 Python Software Foundation. All rights reserved.
7+
Copyright © 2001 Python Software Foundation. All rights reserved.
88

99
Copyright © 2000 BeOpen.com. All rights reserved.
1010

Doc/library/functools.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ The :mod:`functools` module defines the following functions:
453453
.. versionadded:: 3.4
454454

455455

456-
.. function:: reduce(function, iterable[, initial], /)
456+
.. function:: reduce(function, iterable, /[, initial])
457457

458458
Apply *function* of two arguments cumulatively to the items of *iterable*, from
459459
left to right, so as to reduce the iterable to a single value. For example,
@@ -468,7 +468,7 @@ The :mod:`functools` module defines the following functions:
468468

469469
initial_missing = object()
470470

471-
def reduce(function, iterable, initial=initial_missing, /):
471+
def reduce(function, iterable, /, initial=initial_missing):
472472
it = iter(iterable)
473473
if initial is initial_missing:
474474
value = next(it)
@@ -481,6 +481,9 @@ The :mod:`functools` module defines the following functions:
481481
See :func:`itertools.accumulate` for an iterator that yields all intermediate
482482
values.
483483

484+
.. versionchanged:: next
485+
*initial* is now supported as a keyword argument.
486+
484487
.. decorator:: singledispatch
485488

486489
Transform a function into a :term:`single-dispatch <single

Doc/library/tomllib.rst

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,36 @@ This module defines the following functions:
6060

6161
The following exceptions are available:
6262

63-
.. exception:: TOMLDecodeError
63+
.. exception:: TOMLDecodeError(msg, doc, pos)
6464

65-
Subclass of :exc:`ValueError`.
65+
Subclass of :exc:`ValueError` with the following additional attributes:
66+
67+
.. attribute:: msg
68+
69+
The unformatted error message.
70+
71+
.. attribute:: doc
72+
73+
The TOML document being parsed.
74+
75+
.. attribute:: pos
76+
77+
The index of *doc* where parsing failed.
78+
79+
.. attribute:: lineno
80+
81+
The line corresponding to *pos*.
82+
83+
.. attribute:: colno
84+
85+
The column corresponding to *pos*.
86+
87+
.. versionchanged:: next
88+
Added the *msg*, *doc* and *pos* parameters.
89+
Added the :attr:`msg`, :attr:`doc`, :attr:`pos`, :attr:`lineno` and :attr:`colno` attributes.
90+
91+
.. deprecated:: next
92+
Passing free-form positional arguments is deprecated.
6693

6794

6895
Examples

Doc/library/urllib.parse.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ or on combining URL components into a URL string.
239239
query parameter separator. This has been changed to allow only a single
240240
separator key, with ``&`` as the default separator.
241241

242+
.. deprecated:: 3.14
243+
Accepting objects with false values (like ``0`` and ``[]``) except empty
244+
strings and byte-like objects and ``None`` is now deprecated.
245+
242246

243247
.. function:: parse_qsl(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace', max_num_fields=None, separator='&')
244248

@@ -745,6 +749,10 @@ task isn't already covered by the URL parsing functions above.
745749
.. versionchanged:: 3.5
746750
Added the *quote_via* parameter.
747751

752+
.. deprecated:: 3.14
753+
Accepting objects with false values (like ``0`` and ``[]``) except empty
754+
strings and byte-like objects and ``None`` is now deprecated.
755+
748756

749757
.. seealso::
750758

Doc/library/uuid.rst

Lines changed: 33 additions 10000 & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
:mod:`!uuid` --- UUID objects according to :rfc:`4122`
1+
:mod:`!uuid` --- UUID objects according to :rfc:`9562`
22
======================================================
33

44
.. module:: uuid
5-
:synopsis: UUID objects (universally unique identifiers) according to RFC 4122
5+
:synopsis: UUID objects (universally unique identifiers) according to RFC 9562
66
.. moduleauthor:: Ka-Ping Yee <ping@zesty.ca>
77
.. sectionauthor:: George Yoshida <quiver@users.sourceforge.net>
88

@@ -12,7 +12,8 @@
1212

1313
This module provides immutable :class:`UUID` objects (the :class:`UUID` class)
1414
and the functions :func:`uuid1`, :func:`uuid3`, :func:`uuid4`, :func:`uuid5` for
15-
generating version 1, 3, 4, and 5 UUIDs as specified in :rfc:`4122`.
15+
generating version 1, 3, 4, 5, and 8 UUIDs as specified in :rfc:`9562` (which
16+
supersedes :rfc:`4122`).
1617

1718
If all you want is a unique ID, you should probably call :func:`uuid1` or
1819
:func:`uuid4`. Note that :func:`uuid1` may compromise privacy since it creates
@@ -65,7 +66,7 @@ which relays any information about the UUID's safety, using this enumeration:
6566

6667
Exactly one of *hex*, *bytes*, *bytes_le*, *fields*, or *int* must be given.
6768
The *version* argument is optional; if given, the resulting UUID will have its
68-
variant and version number set according to :rfc:`4122`, overriding bits in the
69+
variant and version number set according to :rfc:`9562`, overriding bits in the
6970
given *hex*, *bytes*, *bytes_le*, *fields*, or *int*.
7071

7172
Comparison of UUID objects are made by way of comparing their
@@ -137,7 +138,7 @@ which relays any information about the UUID's safety, using this enumeration:
137138

138139
.. attribute:: UUID.urn
139140

140-
The UUID as a URN as specified in :rfc:`4122`.
141+
The UUID as a URN as specified in :rfc:`9562`.
141142

142143

143144
.. attribute:: UUID.variant
@@ -149,9 +150,13 @@ which relays any information about the UUID's safety, using this enumeration:
149150

150151
.. attribute:: UUID.version
151152

10000
152-
The UUID version number (1 through 5, meaningful only when the variant is
153+
The UUID version number (1 through 8, meaningful only when the variant is
153154
:const:`RFC_4122`).
154155

156+
.. versionchanged:: next
157+
Added UUID version 8.
158+
159+
155160
.. attribute:: UUID.is_safe
156161

157162
An enumeration of :class:`SafeUUID` which indicates whether the platform
@@ -216,6 +221,23 @@ The :mod:`uuid` module defines the following functions:
216221

217222
.. index:: single: uuid5
218223

224+
225+
.. function:: uuid8(a=None, b=None, c=None)
226+
227+
Generate a pseudo-random UUID according to
228+
:rfc:`RFC 9562, §5.8 <9562#section-5.8>`.
229+
230+
When specified, the parameters *a*, *b* and *c* are expected to be
231+
positive integers of 48, 12 and 62 bits respectively. If they exceed
232+
their expected bit count, only their least significant bits are kept;
233+
non-specified arguments are substituted for a pseudo-random integer of
234+
appropriate size.
235+
236+
.. versionadded:: next
237+
238+
.. index:: single: uuid8
239+
240+
219241
The :mod:`uuid` module defines the following namespace identifiers for use with
220242
:func:`uuid3` or :func:`uuid5`.
221243

@@ -252,7 +274,9 @@ of the :attr:`~UUID.variant` attribute:
252274

253275
.. data:: RFC_4122
254276

255-
Specifies the UUID layout given in :rfc:`4122`.
277+
Specifies the UUID layout given in :rfc:`4122`. This constant is kept
278+
for backward compatibility even though :rfc:`4122` has been superseded
279+
by :rfc:`9562`.
256280

257281

258282
.. data:: RESERVED_MICROSOFT
@@ -267,7 +291,7 @@ of the :attr:`~UUID.variant` attribute:
267291

268292
.. seealso::
269293

270-
:rfc:`4122` - A Universally Unique IDentifier (UUID) URN Namespace
294+
:rfc:`9562` - A Universally Unique IDentifier (UUID) URN Namespace
271295
This specification defines a Uniform Resource Name namespace for UUIDs, the
272296
internal format of UUIDs, and methods of generating UUIDs.
273297

@@ -283,7 +307,7 @@ The :mod:`uuid` module can be executed as a script from the command line.
283307

284308
.. code-block:: sh
285309
286-
python -m uuid [-h] [-u {uuid1,uuid3,uuid4,uuid5}] [-n NAMESPACE] [-N NAME]
310+
python -m uuid [-h] [-u {uuid1,uuid3,uuid4,uuid5,uuid8}] [-n NAMESPACE] [-N NAME]
287311
288312
The following options are accepted:
289313

Doc/license.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ PSF LICENSE AGREEMENT FOR PYTHON |release|
100100
analyze, test, perform and/or display publicly, prepare derivative works,
101101
distribute, and otherwise use Python |release| alone or in any derivative
102102
version, provided, however, that PSF's License Agreement and PSF's notice of
103-
copyright, i.e., "Copyright © 2001-2024 Python Software Foundation; All Rights
103+
copyright, i.e., "Copyright © 2001 Python Software Foundation; All Rights
104104
Reserved" are retained in Python |release| alone or in any derivative version
105105
prepared by Licensee.
106106

Doc/whatsnew/3.14.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,11 @@ functools
320320
to reserve a place for positional arguments.
321321
(Contributed by Dominykas Grigonis in :gh:`119127`.)
322322

323+
* Allow the *initial* parameter of :func:`functools.reduce` to be passed
324+
as a keyword argument.
325+
(Contributed by Sayandip Dutta in :gh:`125916`.)
326+
327+
323328
getopt
324329
------
325330

@@ -366,6 +371,16 @@ json
366371
mimetypes
367372
---------
368373

374+
* Add MS and :rfc:`8081` MIME types for fonts:
375+
376+
* Embedded OpenType: ``application/vnd.ms-fontobject``
377+
* OpenType Layout (OTF) ``font/otf``
378+
* TrueType: ``font/ttf``
379+
* WOFF 1.0 ``font/woff``
380+
* WOFF 2.0 ``font/woff2``
381+
382+
(Contributed by Sahil Prajapati and Hugo van Kemenade in :gh:`84852`.)
383+
369384
* Add :rfc:`9559` MIME types for Matroska audiovisual data container
370385
structures, containing:
371386

@@ -502,6 +517,14 @@ unittest
502517
(Contributed by Jacob Walls in :gh:`80958`.)
503518

504519

520+
uuid
521+
----
522+
523+
* Add support for UUID version 8 via :func:`uuid.uuid8` as specified
524+
in :rfc:`9562`.
525+
(Contributed by Bénédikt Tran in :gh:`89083`.)
526+
527+
505528
.. Add improved modules above alphabetically, not here at the end.
506529
507530
Optimizations
@@ -560,6 +583,13 @@ Deprecated
560583
Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest.
561584
(Contributed by Bénédikt Tran in :gh:`119698`.)
562585

586+
* :mod:`urllib.parse`:
587+
Accepting objects with false values (like ``0`` and ``[]``) except empty
588+
strings, byte-like objects and ``None`` in :mod:`urllib.parse` functions
589+
:func:`~urllib.parse.parse_qsl` and :func:`~urllib.parse.parse_qs` is now
590+
deprecated.
591+
(Contributed by Serhiy Storchaka in :gh:`116897`.)
592+
563593
.. Add deprecations above alphabetically, not here at the end.
564594
565595
.. include:: ../deprecations/pending-removal-in-3.15.rst
@@ -792,6 +822,11 @@ New features
792822
an interned string and deallocate it during module shutdown.
793823
(Contributed by Eddie Elizondo in :gh:`113601`.)
794824

825+
* Add :c:func:`PyLong_IsPositive`, :c:func:`PyLong_IsNegative`
826+
and :c:func:`PyLong_IsZero` for checking if :c:type:`PyLongObject`
827+
is positive, negative, or zero, respectively.
828+
(Contribued by James Roy and Sergey B Kirpichev in :gh:`126061`.)
829+
795830
* Add new functions to convert C ``<stdint.h>`` numbers from/to Python
796831
:class:`int`:
797832

Include/cpython/longobject.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,24 @@ PyAPI_FUNC(PyObject*) PyLong_FromUnsignedNativeBytes(const void* buffer,
6161
PyAPI_FUNC(int) PyUnstable_Long_IsCompact(const PyLongObject* op);
6262
PyAPI_FUNC(Py_ssize_t) PyUnstable_Long_CompactValue(const PyLongObject* op);
6363

64+
/* PyLong_IsPositive. Check if the integer object is positive.
65+
66+
- On success, return 1 if *obj is positive, and 0 otherwise.
67+
- On failure, set an exception, and return -1. */
68+
PyAPI_FUNC(int) PyLong_IsPositive(PyObject *obj);
69+
70+
/* PyLong_IsNegative. Check if the integer object is negative.
71+
72+
- On success, return 1 if *obj is negative, and 0 otherwise.
73+
- On failure, set an exception, and return -1. */
74+
PyAPI_FUNC(int) PyLong_IsNegative(PyObject *obj);
75+
76+
/* PyLong_IsZero. Check if the integer object is zero.
77+
78+
- On success, return 1 if *obj is zero, and 0 if it is non-zero.
79+
- On failure, set an exception, and return -1. */
80+
PyAPI_FUNC(int) PyLong_IsZero(PyObject *obj);
81+
6482
/* PyLong_GetSign. Get the sign of an integer object:
6583
0, -1 or +1 for zero, negative or positive integer, respectively.
6684

0 commit comments

Comments
 (0)
0