Skip to content

Commit 83001af

Browse files
committed
Merge branch 'main' into pythongh-77609-glob-follow-symlinks-triple-star
2 parents 2405074 + c0ece3d commit 83001af

File tree

229 files changed

+3258
-1291
lines changed

Some content is hidden

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

229 files changed

+3258
-1291
lines changed

Diff for: Doc/c-api/dict.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Dictionary Objects
154154
155155
.. c:function:: Py_ssize_t PyDict_Size(PyObject *p)
156156
157-
.. index:: builtin: len
157+
.. index:: pair: built-in function; len
158158
159159
Return the number of items in the dictionary. This is equivalent to
160160
``len(p)`` on a dictionary.

Diff for: Doc/c-api/import.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Importing Modules
4141
4242
.. c:function:: PyObject* PyImport_ImportModuleEx(const char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
4343
44-
.. index:: builtin: __import__
44+
.. index:: pair: built-in function; __import__
4545
4646
Import a module. This is best described by referring to the built-in Python
4747
function :func:`__import__`.
@@ -120,7 +120,7 @@ Importing Modules
120120
121121
.. c:function:: PyObject* PyImport_ExecCodeModule(const char *name, PyObject *co)
122122
123-
.. index:: builtin: compile
123+
.. index:: pair: built-in function; compile
124124
125125
Given a module name (possibly of the form ``package.module``) and a code object
126126
read from a Python bytecode file or obtained from the built-in function

Diff for: Doc/c-api/list.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ List Objects
4545
4646
.. c:function:: Py_ssize_t PyList_Size(PyObject *list)
4747
48-
.. index:: builtin: len
48+
.. index:: pair: built-in function; len
4949
5050
Return the length of the list object in *list*; this is equivalent to
5151
``len(list)`` on a list object.
@@ -138,7 +138,7 @@ List Objects
138138
139139
.. c:function:: PyObject* PyList_AsTuple(PyObject *list)
140140
141-
.. index:: builtin: tuple
141+
.. index:: pair: built-in function; tuple
142142
143143
Return a new tuple object containing the contents of *list*; equivalent to
144144
``tuple(list)``.

Diff for: Doc/c-api/mapping.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ See also :c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem` and
2020
.. c:function:: Py_ssize_t PyMapping_Size(PyObject *o)
2121
Py_ssize_t PyMapping_Length(PyObject *o)
2222
23-
.. index:: builtin: len
23+
.. index:: pair: built-in function; len
2424
2525
Returns the number of keys in object *o* on success, and ``-1`` on failure.
2626
This is equivalent to the Python expression ``len(o)``.

Diff for: Doc/c-api/number.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ Number Protocol
6464
6565
.. c:function:: PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2)
6666
67-
.. index:: builtin: divmod
67+
.. index:: pair: built-in function; divmod
6868
6969
See the built-in function :func:`divmod`. Returns ``NULL`` on failure. This is
7070
the equivalent of the Python expression ``divmod(o1, o2)``.
7171
7272
7373
.. c:function:: PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3)
7474
75-
.. index:: builtin: pow
75+
.. index:: pair: built-in function; pow
7676
7777
See the built-in function :func:`pow`. Returns ``NULL`` on failure. This is the
7878
equivalent of the Python expression ``pow(o1, o2, o3)``, where *o3* is optional.
@@ -94,7 +94,7 @@ Number Protocol
9494
9595
.. c:function:: PyObject* PyNumber_Absolute(PyObject *o)
9696
97-
.. index:: builtin: abs
97+
.. index:: pair: built-in function; abs
9898
9999
Returns the absolute value of *o*, or ``NULL`` on failure. This is the equivalent
100100
of the Python expression ``abs(o)``.
@@ -192,7 +192,7 @@ Number Protocol
192192
193193
.. c:function:: PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3)
194194
195-
.. index:: builtin: pow
195+
.. index:: pair: built-in function; pow
196196
197197
See the built-in function :func:`pow`. Returns ``NULL`` on failure. The operation
198198
is done *in-place* when *o1* supports it. This is the equivalent of the Python
@@ -238,15 +238,15 @@ Number Protocol
238238
239239
.. c:function:: PyObject* PyNumber_Long(PyObject *o)
240240
241-
.. index:: builtin: int
241+
.. index:: pair: built-in function; int
242242
243243
Returns the *o* converted to an integer object on success, or ``NULL`` on
244244
failure. This is the equivalent of the Python expression ``int(o)``.
245245
246246
247247
.. c:function:: PyObject* PyNumber_Float(PyObject *o)
248248
249-
.. index:: builtin: float
249+
.. index:: pair: built-in function; float
250250
251251
Returns the *o* converted to a float object on success, or ``NULL`` on failure.
252252
This is the equivalent of the Python expression ``float(o)``.

Diff for: Doc/c-api/object.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Object Protocol
190190
191191
.. c:function:: PyObject* PyObject_Repr(PyObject *o)
192192
193-
.. index:: builtin: repr
193+
.. index:: pair: built-in function; repr
194194
195195
Compute a string representation of object *o*. Returns the string
196196
representation on success, ``NULL`` on failure. This is the equivalent of the
@@ -202,7 +202,7 @@ Object Protocol
202202
203203
.. c:function:: PyObject* PyObject_ASCII(PyObject *o)
204204
205-
.. index:: builtin: ascii
205+
.. index:: pair: built-in function; ascii
206206
207207
As :c:func:`PyObject_Repr`, compute a string representation of object *o*, but
208208
escape the non-ASCII characters in the string returned by
@@ -227,7 +227,7 @@ Object Protocol
227227
228228
.. c:function:: PyObject* PyObject_Bytes(PyObject *o)
229229
230-
.. index:: builtin: bytes
230+
.. index:: pair: built-in function; bytes
231231
232232
Compute a bytes representation of object *o*. ``NULL`` is returned on
233233
failure and a bytes object on success. This is equivalent to the Python
@@ -278,7 +278,7 @@ Object Protocol
278278
279279
.. c:function:: Py_hash_t PyObject_Hash(PyObject *o)
280280
281-
.. index:: builtin: hash
281+
.. index:: pair: built-in function; hash
282282
283283
Compute and return the hash value of an object *o*. On failure, return ``-1``.
284284
This is the equivalent of the Python expression ``hash(o)``.
@@ -312,7 +312,7 @@ Object Protocol
312312
313313
.. c:function:: PyObject* PyObject_Type(PyObject *o)
314314
315-
.. index:: builtin: type
315+
.. index:: pair: built-in function; type
316316
317317
When *o* is non-``NULL``, returns a type object corresponding to the object type
318318
of object *o*. On failure, raises :exc:`SystemError` and returns ``NULL``. This
@@ -332,7 +332,7 @@ Object Protocol
332332
.. c:function:: Py_ssize_t PyObject_Size(PyObject *o)
333333
Py_ssize_t PyObject_Length(PyObject *o)
334334
335-
.. index:: builtin: len
335+
.. index:: pair: built-in function; len
336336
337337
Return the length of object *o*. If the object *o* provides either the sequence
338338
and mapping protocols, the sequence length is returned. On error, ``-1`` is

Diff for: Doc/c-api/sequence.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Sequence Protocol
1818
.. c:function:: Py_ssize_t PySequence_Size(PyObject *o)
1919
Py_ssize_t PySequence_Length(PyObject *o)
2020
21-
.. index:: builtin: len
21+
.. index:: pair: built-in function; len
2222
2323
Returns the number of objects in sequence *o* on success, and ``-1`` on
2424
failure. This is equivalent to the Python expression ``len(o)``.
@@ -120,7 +120,7 @@ Sequence Protocol
120120
121121
.. c:function:: PyObject* PySequence_Tuple(PyObject *o)
122122
123-
.. index:: builtin: tuple
123+
.. index:: pair: built-in function; tuple
124124
125125
Return a tuple object with the same contents as the sequence or iterable *o*,
126126
or ``NULL`` on failure. If *o* is a tuple, a new reference will be returned,

Diff for: Doc/c-api/set.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ or :class:`frozenset` or instances of their subtypes.
107107
108108
.. c:function:: Py_ssize_t PySet_Size(PyObject *anyset)
109109
110-
.. index:: builtin: len
110+
.. index:: pair: built-in function; len
111111
112112
Return the length of a :class:`set` or :class:`frozenset` object. Equivalent to
113113
``len(anyset)``. Raises a :exc:`PyExc_SystemError` if *anyset* is not a

Diff for: Doc/c-api/structures.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ method.
347347
348348
.. data:: METH_CLASS
349349
350-
.. index:: builtin: classmethod
350+
.. index:: pair: built-in function; classmethod
351351
352352
The method will be passed the type object as the first parameter rather
353353
than an instance of the type. This is used to create *class methods*,
@@ -357,7 +357,7 @@ method.
357357
358358
.. data:: METH_STATIC
359359
360-
.. index:: builtin: staticmethod
360+
.. index:: pair: built-in function; staticmethod
361361
362362
The method will be passed ``NULL`` as the first parameter rather than an
363363
instance of the type. This is used to create *static methods*, similar to

Diff for: Doc/c-api/typeobj.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ and :c:type:`PyType_Type` effectively act as defaults.)
805805

806806
.. c:member:: reprfunc PyTypeObject.tp_repr
807807
808-
.. index:: builtin: repr
808+
.. index:: pair: built-in function; repr
809809

810810
An optional pointer to a function that implements the built-in function
811811
:func:`repr`.
@@ -870,7 +870,7 @@ and :c:type:`PyType_Type` effectively act as defaults.)
870870

871871
.. c:member:: hashfunc PyTypeObject.tp_hash
872872
873-
.. index:: builtin: hash
873+
.. index:: pair: built-in function; hash
874874

875875
An optional pointer to a function that implements the built-in function
876876
:func:`hash`.

Diff for: Doc/extending/newtypes.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ done. This can be done using the :c:func:`PyErr_Fetch` and
149149

150150
.. index::
151151
single: string; object representation
152-
builtin: repr
152+
pair: built-in function; repr
153153

154154
Object Presentation
155155
-------------------

Diff for: Doc/howto/clinic.rst

+28-13
Original file line numberDiff line numberDiff line change
@@ -1033,19 +1033,36 @@ you're not permitted to use:
10331033
Using a return converter
10341034
------------------------
10351035

1036-
By default the impl function Argument Clinic generates for you returns ``PyObject *``.
1037-
But your C function often computes some C type, then converts it into the ``PyObject *``
1036+
By default, the impl function Argument Clinic generates for you returns
1037+
:c:type:`PyObject * <PyObject>`.
1038+
But your C function often computes some C type,
1039+
then converts it into the :c:type:`!PyObject *`
10381040
at the last moment. Argument Clinic handles converting your inputs from Python types
10391041
into native C types—why not have it convert your return value from a native C type
10401042
into a Python type too?
10411043

10421044
That's what a "return converter" does. It changes your impl function to return
10431045
some C type, then adds code to the generated (non-impl) function to handle converting
1044-
that value into the appropriate ``PyObject *``.
1046+
that value into the appropriate :c:type:`!PyObject *`.
10451047

10461048
The syntax for return converters is similar to that of parameter converters.
10471049
You specify the return converter like it was a return annotation on the
1048-
function itself. Return converters behave much the same as parameter converters;
1050+
function itself, using ``->`` notation.
1051+
1052+
For example:
1053+
1054+
.. code-block:: c
1055+
1056+
/*[clinic input]
1057+
add -> int
1058+
1059+
a: int
1060+
b: int
1061+
/
1062+
1063+
[clinic start generated code]*/
1064+
1065+
Return converters behave much the same as parameter converters;
10491066
they take arguments, the arguments are all keyword-only, and if you're not changing
10501067
any of the default arguments you can omit the parentheses.
10511068

@@ -1066,19 +1083,17 @@ Currently Argument Clinic supports only a few return converters:
10661083
.. code-block:: none
10671084
10681085
bool
1086+
double
1087+
float
10691088
int
1070-
unsigned int
10711089
long
1072-
unsigned int
1073-
size_t
10741090
Py_ssize_t
1075-
float
1076-
double
1077-
DecodeFSDefault
1091+
size_t
1092+
unsigned int
1093+
unsigned long
10781094
1079-
None of these take parameters. For the first three, return -1 to indicate
1080-
error. For ``DecodeFSDefault``, the return type is ``const char *``; return a ``NULL``
1081-
pointer to indicate an error.
1095+
None of these take parameters.
1096+
For all of these, return ``-1`` to indicate error.
10821097

10831098
To see all the return converters Argument Clinic supports, along with
10841099
their parameters (if any),

Diff for: Doc/library/asyncio-task.rst

+8-4
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ Introspection
10141014
Task Object
10151015
===========
10161016

1017-
.. class:: Task(coro, *, loop=None, name=None)
1017+
.. class:: Task(coro, *, loop=None, name=None, context=None)
10181018

10191019
A :class:`Future-like <Future>` object that runs a Python
10201020
:ref:`coroutine <coroutine>`. Not thread-safe.
@@ -1049,9 +1049,10 @@ Task Object
10491049
APIs except :meth:`Future.set_result` and
10501050
:meth:`Future.set_exception`.
10511051

1052-
Tasks support the :mod:`contextvars` module. When a Task
1053-
is created it copies the current context and later runs its
1054-
coroutine in the copied context.
1052+
An optional keyword-only *context* argument allows specifying a
1053+
custom :class:`contextvars.Context` for the *coro* to run in.
1054+
If no *context* is provided, the Task copies the current context
1055+
and later runs its coroutine in the copied context.
10551056

10561057
.. versionchanged:: 3.7
10571058
Added support for the :mod:`contextvars` module.
@@ -1063,6 +1064,9 @@ Task Object
10631064
Deprecation warning is emitted if *loop* is not specified
10641065
and there is no running event loop.
10651066

1067+
.. versionchanged:: 3.11
1068+
Added the *context* parameter.
1069+
10661070
.. method:: done()
10671071

10681072
Return ``True`` if the Task is *done*.

Diff for: Doc/library/dis.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ iterations of the loop.
13671367

13681368
.. opcode:: BUILD_SLICE (argc)
13691369

1370-
.. index:: builtin: slice
1370+
.. index:: pair: built-in function; slice
13711371

13721372
Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2, implements::
13731373

Diff for: Doc/library/functions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ are always available. They are listed here in alphabetical order.
562562
Raises an :ref:`auditing event <auditing>` ``exec`` with the code object
563563
as the argument. Code compilation events may also be raised.
564564

565-
.. index:: builtin: exec
565+
.. index:: pair: built-in function; exec
566566

567567
.. function:: exec(object, globals=None, locals=None, /, *, closure=None)
568568

Diff for: Doc/library/functools.rst

+4-12
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,10 @@ The :mod:`functools` module defines the following functions:
110110
``__slots__`` without including ``__dict__`` as one of the defined slots
111111
(as such classes don't provide a ``__dict__`` attribute at all).
112112

113-
If a mutable mapping is not available or if space-efficient key sharing
114-
is desired, an effect similar to :func:`cached_property` can be achieved
115-
by a stacking :func:`property` on top of :func:`cache`::
116-
117-
class DataSet:
118-
def __init__(self, sequence_of_numbers):
119-
self._data = sequence_of_numbers
120-
121-
@property
122-
@cache
123-
def stdev(self):
124-
return statistics.stdev(self._data)
113+
If a mutable mapping is not available or if space-efficient key sharing is
114+
desired, an effect similar to :func:`cached_property` can also be achieved by
115+
stacking :func:`property` on top of :func:`lru_cache`. See
116+
:ref:`faq-cache-method-calls` for more details on how this differs from :func:`cached_property`.
125117

126118
.. versionadded:: 3.8
127119

0 commit comments

Comments
 (0)