Skip to content

Commit 2df6f41

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 00661fc + d9e2512 commit 2df6f41

File tree

163 files changed

+1982
-786
lines changed

Some content is hidden

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

163 files changed

+1982
-786
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ configure* @erlend-aasland @corona10
1616
Makefile.pre.in @erlend-aasland
1717
Modules/Setup* @erlend-aasland
1818

19+
# argparse
20+
**/*argparse* @savannahostrowski
21+
1922
# asyncio
2023
**/*asyncio* @1st1 @asvetlov @kumaraditya303 @willingc
2124

2225
# Core
2326
**/*context* @1st1
2427
**/*genobject* @markshannon
2528
**/*hamt* @1st1
26-
**/*jit* @brandtbucher
29+
**/*jit* @brandtbucher @savannahostrowski
2730
Objects/set* @rhettinger
2831
Objects/dict* @methane @markshannon
2932
Objects/typevarobject.c @JelleZijlstra

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
# reproducible: to get the same tools versions (autoconf, aclocal, ...)
4747
runs-on: ubuntu-24.04
4848
container:
49-
image: ghcr.io/python/autoconf:2024.10.16.11360930377
49+
image: ghcr.io/python/autoconf:2024.11.11.11786316759
5050
timeout-minutes: 60
5151
needs: check_source
5252
if: needs.check_source.outputs.run_tests == 'true'

Doc/c-api/object.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,3 +575,27 @@ Object Protocol
575575
has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set.
576576
577577
.. versionadded:: 3.13
578+
579+
.. c:function:: int PyUnstable_Object_EnableDeferredRefcount(PyObject *obj)
580+
581+
Enable `deferred reference counting <https://peps.python.org/pep-0703/#deferred-reference-counting>`_ on *obj*,
582+
if supported by the runtime. In the :term:`free-threaded <free threading>` build,
583+
this allows the interpreter to avoid reference count adjustments to *obj*,
584+
which may improve multi-threaded performance. The tradeoff is
585+
that *obj* will only be deallocated by the tracing garbage collector.
586+
587+
This function returns ``1`` if deferred reference counting is enabled on *obj*
588+
(including when it was enabled before the call),
589+
and ``0`` if deferred reference counting is not supported or if the hint was
590+
ignored by the runtime. This function is thread-safe, and cannot fail.
591+
592+
This function does nothing on builds with the :term:`GIL` enabled, which do
593+
not support deferred reference counting. This also does nothing if *obj* is not
594+
an object tracked by the garbage collector (see :func:`gc.is_tracked` and
595+
:c:func:`PyObject_GC_IsTracked`).
596+
597+
This function is intended to be used soon after *obj* is created,
598+
by the code that creates it.
599+
600+
.. versionadded:: next
601+

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/data/refcounts.dat

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,19 @@ PyLong_FromUnsignedLong:unsignedlong:v::
12841284
PyLong_FromVoidPtr:PyObject*::+1:
12851285
PyLong_FromVoidPtr:void*:p::
12861286

1287+
PyLong_IsPositive:int:::
1288+
PyLong_IsPositive:PyObject*:obj:0:
1289+
1290+
PyLong_IsNegative:int:::
1291+
PyLong_IsNegative:PyObject*:obj:0:
1292+
1293+
PyLong_IsZero:int:::
1294+
PyLong_IsZero:PyObject*:obj:0:
1295+
1296+
PyLong_GetSign:int:::
1297+
PyLong_GetSign:PyObject*:v:0:
1298+
PyLong_GetSign:int*:sign::
1299+
12871300
PyMapping_Check:int:::
12881301
PyMapping_Check:PyObject*:o:0:
12891302

Doc/library/getopt.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ exception:
8585
variable :envvar:`!POSIXLY_CORRECT` is set, then option processing stops as
8686
soon as a non-option argument is encountered.
8787

88+
If the first character of the option string is ``'-'``, non-option arguments
89+
that are followed by options are added to the list of option-and-value pairs
90+
as a pair that has ``None`` as its first element and the list of non-option
91+
arguments as its second element.
92+
The second element of the :func:`!gnu_getopt` result is a list of
93+
program arguments after the last option.
94+
95+
.. versionchanged:: 3.14
96+
Support for returning intermixed options and non-option arguments in order.
97+
8898

8999
.. exception:: GetoptError
90100

@@ -144,6 +154,20 @@ Optional arguments should be specified explicitly:
144154
>>> args
145155
['a1', 'a2']
146156

157+
The order of options and non-option arguments can be preserved:
158+
159+
.. doctest::
160+
161+
>>> s = 'a1 -x a2 a3 a4 --long a5 a6'
162+
>>> args = s.split()
163+
>>> args
164+
['a1', '-x', 'a2', 'a3', 'a4', '--long', 'a5', 'a6']
165+
>>> optlist, args = getopt.gnu_getopt(args, '-x:', ['long='])
166+
>>> optlist
167+
[(None, ['a1']), ('-x', 'a2'), (None, ['a3', 'a4']), ('--long', 'a5')]
168+
>>> args
169+
['a6']
170+
147171
In a script, typical usage is something like this:
148172

149173
.. testcode::

Doc/library/pprint.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ let's fetch information about a project from `PyPI <https://pypi.org>`_::
267267
>>> import json
268268
>>> import pprint
269269
>>> from urllib.request import urlopen
270-
>>> with urlopen('https://pypi.org/pypi/sampleproject/json') as resp:
270+
>>> with urlopen('https://pypi.org/pypi/sampleproject/1.2.0/json') as resp:
271271
... project_info = json.load(resp)['info']
272272

273273
In its basic form, :func:`~pprint.pp` shows the whole object::

Doc/library/socket.rst

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,9 @@ The :mod:`socket` module also offers various network-related services:
928928

929929
.. versionadded:: 3.7
930930

931-
.. function:: getaddrinfo(host, port, family=0, type=0, proto=0, flags=0)
931+
.. function:: getaddrinfo(host, port, family=AF_UNSPEC, type=0, proto=0, flags=0)
932+
933+
This function wraps the C function ``getaddrinfo`` of the underlying system.
932934

933935
Translate the *host*/*port* argument into a sequence of 5-tuples that contain
934936
all the necessary arguments for creating a socket connected to that service.
@@ -938,8 +940,10 @@ The :mod:`socket` module also offers various network-related services:
938940
and *port*, you can pass ``NULL`` to the underlying C API.
939941

940942
The *family*, *type* and *proto* arguments can be optionally specified
941-
in order to narrow the list of addresses returned. Passing zero as a
942-
value for each of these arguments selects the full range of results.
943+
in order to provide options and limit the list of addresses returned.
944+
Pass their default values (:data:`AF_UNSPEC`, 0, and 0, respectively)
945+
to not limit the results. See the note below for details.
946+
943947
The *flags* argument can be one or several of the ``AI_*`` constants,
944948
and will influence how results are computed and returned.
945949
For example, :const:`AI_NUMERICHOST` will disable domain name resolution
@@ -959,6 +963,29 @@ The :mod:`socket` module also offers various network-related services:
959963
:const:`AF_INET6`), and is meant to be passed to the :meth:`socket.connect`
960964
method.
961965

966+
.. note::
967+
968+
If you intend to use results from :func:`!getaddrinfo` to create a socket
969+
(rather than, for example, retrieve *canonname*),
970+
consider limiting the results by *type* (e.g. :data:`SOCK_STREAM` or
971+
:data:`SOCK_DGRAM`) and/or *proto* (e.g. :data:`IPPROTO_TCP` or
972+
:data:`IPPROTO_UDP`) that your application can handle.
973+
974+
The behavior with default values of *family*, *type*, *proto*
975+
and *flags* is system-specific.
976+
977+
Many systems (for example, most Linux configurations) will return a sorted
978+
list of all matching addresses.
979+
These addresses should generally be tried in order until a connection succeeds
980+
(possibly tried in parallel, for example, using a `Happy Eyeballs`_ algorithm).
981+
In these cases, limiting the *type* and/or *proto* can help eliminate
982+
unsuccessful or unusable connecton attempts.
983+
984+
Some systems will, however, only return a single address.
985+
(For example, this was reported on Solaris and AIX configurations.)
986+
On these systems, limiting the *type* and/or *proto* helps ensure that
987+
this address is usable.
988+
962989
.. audit-event:: socket.getaddrinfo host,port,family,type,protocol socket.getaddrinfo
963990

964991
The following example fetches address information for a hypothetical TCP
@@ -978,6 +1005,8 @@ The :mod:`socket` module also offers various network-related services:
9781005
for IPv6 multicast addresses, string representing an address will not
9791006
contain ``%scope_id`` part.
9801007

1008+
.. _Happy Eyeballs: https://en.wikipedia.org/wiki/Happy_Eyeballs
1009+
9811010
.. function:: getfqdn([name])
9821011

9831012
Return a fully qualified domain name for *name*. If *name* is omitted or empty,

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

0 commit comments

Comments
 (0)