Skip to content

Commit 55dad5e

Browse files
authored
Merge branch 'python:main' into feat/defer-expr
2 parents f1ce690 + 91f4908 commit 55dad5e

Some content is hidden

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

70 files changed

+333
-71
lines changed

.github/workflows/build.yml

+1-1
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

+33
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

+1-4
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

+1-1
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

+5-2
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/license.rst

+1-1
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

+10
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

@@ -802,6 +807,11 @@ New features
802807
an interned string and deallocate it during module shutdown.
803808
(Contributed by Eddie Elizondo in :gh:`113601`.)
804809

810+
* Add :c:func:`PyLong_IsPositive`, :c:func:`PyLong_IsNegative`
811+
and :c:func:`PyLong_IsZero` for checking if :c:type:`PyLongObject`
812+
is positive, negative, or zero, respectively.
813+
(Contribued by James Roy and Sergey B Kirpichev in :gh:`126061`.)
814+
805815
* Add new functions to convert C ``<stdint.h>`` numbers from/to Python
806816
:class:`int`:
807817

Include/cpython/longobject.h

+18
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

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
8383
analyze, test, perform and/or display publicly, prepare derivative works,
8484
distribute, and otherwise use Python alone or in any derivative version,
8585
provided, however, that PSF's License Agreement and PSF's notice of copyright,
86-
i.e., "Copyright (c) 2001-2024 Python Software Foundation; All Rights Reserved"
86+
i.e., "Copyright (c) 2001 Python Software Foundation; All Rights Reserved"
8787
are retained in Python alone or in any derivative version prepared by Licensee.
8888

8989
3. In the event Licensee prepares a derivative work that is based on

Lib/email/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2007 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Barry Warsaw
33
44

Lib/email/_parseaddr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2002-2007 Python Software Foundation
1+
# Copyright (C) 2002 Python Software Foundation
22
33

44
"""Email address parsing code.

Lib/email/base64mime.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2002-2007 Python Software Foundation
1+
# Copyright (C) 2002 Python Software Foundation
22
# Author: Ben Gertzfield
33
44

Lib/email/charset.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2007 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Ben Gertzfield, Barry Warsaw
33
44

Lib/email/encoders.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2006 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Barry Warsaw
33
44

Lib/email/errors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2006 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Barry Warsaw
33
44

Lib/email/feedparser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2004-2006 Python Software Foundation
1+
# Copyright (C) 2004 Python Software Foundation
22
# Authors: Baxter, Wouters and Warsaw
33
44

Lib/email/generator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2010 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Barry Warsaw
33
44

Lib/email/header.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2002-2007 Python Software Foundation
1+
# Copyright (C) 2002 Python Software Foundation
22
# Author: Ben Gertzfield, Barry Warsaw
33
44

Lib/email/iterators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2006 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Barry Warsaw
33
44

Lib/email/message.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2007 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Barry Warsaw
33
44

Lib/email/mime/application.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2006 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Keith Dart
33
44

Lib/email/mime/audio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2007 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Anthony Baxter
33
44

Lib/email/mime/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2006 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Barry Warsaw
33
44

Lib/email/mime/image.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2006 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Barry Warsaw
33
44

Lib/email/mime/message.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2006 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Barry Warsaw
33
44

Lib/email/mime/multipart.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2002-2006 Python Software Foundation
1+
# Copyright (C) 2002 Python Software Foundation
22
# Author: Barry Warsaw
33
44

Lib/email/mime/nonmultipart.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2002-2006 Python Software Foundation
1+
# Copyright (C) 2002 Python Software Foundation
22
# Author: Barry Warsaw
33
44

Lib/email/mime/text.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2006 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Barry Warsaw
33
44

Lib/email/parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2007 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Barry Warsaw, Thomas Wouters, Anthony Baxter
33
44

Lib/email/quoprimime.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2006 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Ben Gertzfield
33
44

Lib/email/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2010 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# Author: Barry Warsaw
33
44

Lib/functools.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Written by Nick Coghlan <ncoghlan at gmail.com>,
77
# Raymond Hettinger <python at rcn.com>,
88
# and Łukasz Langa <lukasz at langa.pl>.
9-
# Copyright (C) 2006-2024 Python Software Foundation.
9+
# Copyright (C) 2006 Python Software Foundation.
1010
# See C source code for _functools credits/copyright
1111

1212
__all__ = ['update_wrapper', 'wraps', 'WRAPPER_ASSIGNMENTS', 'WRAPPER_UPDATES',
@@ -236,7 +236,7 @@ def __ge__(self, other):
236236

237237
def reduce(function, sequence, initial=_initial_missing):
238238
"""
239-
reduce(function, iterable[, initial], /) -> value
239+
reduce(function, iterable, /[, initial]) -> value
240240
241241
Apply a function of two arguments cumulatively to the items of an iterable, from left to right.
242242

Lib/optparse.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
__copyright__ = """
4545
Copyright (c) 2001-2006 Gregory P. Ward. All rights reserved.
46-
Copyright (c) 2002-2006 Python Software Foundation. All rights reserved.
46+
Copyright (c) 2002 Python Software Foundation. All rights reserved.
4747
4848
Redistribution and use in source and binary forms, with or without
4949
modification, are permitted provided that the following conditions are

Lib/test/test_capi/test_long.py

+45
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,51 @@ def test_long_getsign(self):
643643

644644
# CRASHES getsign(NULL)
645645

646+
def test_long_ispositive(self):
647+
# Test PyLong_IsPositive()
648+
ispositive = _testcapi.pylong_ispositive
649+
self.assertEqual(ispositive(1), 1)
650+
self.assertEqual(ispositive(123), 1)
651+
self.assertEqual(ispositive(-1), 0)
652+
self.assertEqual(ispositive(0), 0)
653+
self.assertEqual(ispositive(True), 1)
654+
self.assertEqual(ispositive(False), 0)
655+
self.assertEqual(ispositive(IntSubclass(-1)), 0)
656+
self.assertRaises(TypeError, ispositive, 1.0)
657+
self.assertRaises(TypeError, ispositive, Index(123))
658+
659+
# CRASHES ispositive(NULL)
660+
661+
def test_long_isnegative(self):
662+
# Test PyLong_IsNegative()
663+
isnegative = _testcapi.pylong_isnegative
664+
self.assertEqual(isnegative(1), 0)
665+
self.assertEqual(isnegative(123), 0)
666+
self.assertEqual(isnegative(-1), 1)
667+
self.assertEqual(isnegative(0), 0)
668+
self.assertEqual(isnegative(True), 0)
669+
self.assertEqual(isnegative(False), 0)
670+
self.assertEqual(isnegative(IntSubclass(-1)), 1)
671+
self.assertRaises(TypeError, isnegative, 1.0)
672+
self.assertRaises(TypeError, isnegative, Index(123))
673+
674+
# CRASHES isnegative(NULL)
675+
676+
def test_long_iszero(self):
677+
# Test PyLong_IsZero()
678+
iszero = _testcapi.pylong_iszero
679+
self.assertEqual(iszero(1), 0)
680+
self.assertEqual(iszero(-1), 0)
681+
self.assertEqual(iszero(0), 1)
682+
self.assertEqual(iszero(True), 0)
683+
self.assertEqual(iszero(False), 1)
684+
self.assertEqual(iszero(IntSubclass(-1)), 0)
685+
self.assertEqual(iszero(IntSubclass(0)), 1)
686+
self.assertRaises(TypeError, iszero, 1.0)
687+
self.assertRaises(TypeError, iszero, Index(123))
688+
689+
# CRASHES iszero(NULL)
690+
646691
def test_long_asint32(self):
647692
# Test PyLong_AsInt32() and PyLong_FromInt32()
648693
to_int32 = _testlimitedcapi.pylong_asint32

Lib/test/test_csv.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001,2002 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
# csv package unit tests
33

44
import copy

Lib/test/test_email/test_asian_codecs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2002-2006 Python Software Foundation
1+
# Copyright (C) 2002 Python Software Foundation
22
33
# email package unit tests for (optional) Asian codecs
44

Lib/test/test_email/test_email.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2001-2010 Python Software Foundation
1+
# Copyright (C) 2001 Python Software Foundation
22
33
# email package unit tests
44

Lib/test/test_email/torture_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2002-2004 Python Software Foundation
1+
# Copyright (C) 2002 Python Software Foundation
22
#
33
# A torture test of the email package. This should not be run as part of the
44
# standard Python test suite since it requires several meg of email messages

0 commit comments

Comments
 (0)