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

Skip to content

Commit 6b4a598

Browse files
committed
Catch up with main
2 parents 7638b76 + 6e9f83d commit 6b4a598

156 files changed

Lines changed: 5538 additions & 2516 deletions

File tree

Some content is hidden

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

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Parser/parser.c generated
8585
Parser/token.c generated
8686
Programs/test_frozenmain.h generated
8787
Python/Python-ast.c generated
88+
Python/executor_cases.c.h generated
8889
Python/generated_cases.c.h generated
8990
Python/opcode_metadata.h generated
9091
Python/opcode_targets.h generated

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ repos:
33
rev: v4.4.0
44
hooks:
55
- id: check-yaml
6+
- id: end-of-file-fixer
7+
types: [python]
8+
exclude: Lib/test/coding20731.py
69
- id: trailing-whitespace
710
types_or: [c, python, rst]
811

Doc/c-api/dict.rst

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ Dictionary Objects
9898
Return the object from dictionary *p* which has a key *key*. Return ``NULL``
9999
if the key *key* is not present, but *without* setting an exception.
100100
101-
Note that exceptions which occur while calling :meth:`__hash__` and
102-
:meth:`__eq__` methods will get suppressed.
103-
To get error reporting use :c:func:`PyDict_GetItemWithError()` instead.
101+
.. note::
102+
103+
Exceptions that occur while this calls :meth:`~object.__hash__` and
104+
:meth:`~object.__eq__` methods are silently ignored.
105+
Prefer the :c:func:`PyDict_GetItemWithError` function instead.
104106
105107
.. versionchanged:: 3.10
106108
Calling this API without :term:`GIL` held had been allowed for historical
@@ -120,10 +122,13 @@ Dictionary Objects
120122
This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as a
121123
:c:expr:`const char*`, rather than a :c:expr:`PyObject*`.
122124
123-
Note that exceptions which occur while calling :meth:`__hash__` and
124-
:meth:`__eq__` methods and creating a temporary string object
125-
will get suppressed.
126-
To get error reporting use :c:func:`PyDict_GetItemWithError()` instead.
125+
.. note::
126+
127+
Exceptions that occur while this calls :meth:`~object.__hash__` and
128+
:meth:`~object.__eq__` methods or while creating the temporary :class:`str`
129+
object are silently ignored.
130+
Prefer using the :c:func:`PyDict_GetItemWithError` function with your own
131+
:c:func:`PyUnicode_FromString` *key* instead.
127132
128133
129134
.. c:function:: PyObject* PyDict_SetDefault(PyObject *p, PyObject *key, PyObject *defaultobj)

Doc/c-api/list.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ List Objects
8686
Macro form of :c:func:`PyList_SetItem` without error checking. This is
8787
normally only used to fill in new lists where there is no previous content.
8888
89+
Bounds checking is performed as an assertion if Python is built in
90+
:ref:`debug mode <debug-build>` or :option:`with assertions
91+
<--with-assertions>`.
92+
8993
.. note::
9094
9195
This macro "steals" a reference to *item*, and, unlike

Doc/c-api/object.rst

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ Object Protocol
3333
is equivalent to the Python expression ``hasattr(o, attr_name)``. This function
3434
always succeeds.
3535
36-
Note that exceptions which occur while calling :meth:`__getattr__` and
37-
:meth:`__getattribute__` methods will get suppressed.
38-
To get error reporting use :c:func:`PyObject_GetAttr()` instead.
36+
.. note::
37+
38+
Exceptions that occur when this calls :meth:`~object.__getattr__` and
39+
:meth:`~object.__getattribute__` methods are silently ignored.
40+
For proper error handling, use :c:func:`PyObject_GetAttr` instead.
3941
4042
4143
.. c:function:: int PyObject_HasAttrString(PyObject *o, const char *attr_name)
@@ -44,10 +46,12 @@ Object Protocol
4446
is equivalent to the Python expression ``hasattr(o, attr_name)``. This function
4547
always succeeds.
4648
47-
Note that exceptions which occur while calling :meth:`__getattr__` and
48-
:meth:`__getattribute__` methods and creating a temporary string object
49-
will get suppressed.
50-
To get error reporting use :c:func:`PyObject_GetAttrString()` instead.
49+
.. note::
50+
51+
Exceptions that occur when this calls :meth:`~object.__getattr__` and
52+
:meth:`~object.__getattribute__` methods or while creating the temporary :class:`str`
53+
object are silently ignored.
54+
For proper error handling, use :c:func:`PyObject_GetAttrString` instead.
5155
5256
5357
.. c:function:: PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name)

Doc/c-api/tuple.rst

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ Tuple Objects
8989
Like :c:func:`PyTuple_SetItem`, but does no error checking, and should *only* be
9090
used to fill in brand new tuples.
9191
92+
Bounds checking is performed as an assertion if Python is built in
93+
:ref:`debug mode <debug-build>` or :option:`with assertions <--with-assertions>`.
94+
9295
.. note::
9396
9497
This function "steals" a reference to *o*, and, unlike
@@ -194,12 +197,17 @@ type.
194197
.. c:function:: PyObject* PyStructSequence_GetItem(PyObject *p, Py_ssize_t pos)
195198
196199
Return the object at position *pos* in the struct sequence pointed to by *p*.
197-
No bounds checking is performed.
200+
201+
Bounds checking is performed as an assertion if Python is built in
202+
:ref:`debug mode <debug-build>` or :option:`with assertions <--with-assertions>`.
198203
199204
200205
.. c:function:: PyObject* PyStructSequence_GET_ITEM(PyObject *p, Py_ssize_t pos)
201206
202-
Macro equivalent of :c:func:`PyStructSequence_GetItem`.
207+
Alias to :c:func:`PyStructSequence_GetItem`.
208+
209+
.. versionchanged:: 3.13
210+
Now implemented as an alias to :c:func:`PyStructSequence_GetItem`.
203211
204212
205213
.. c:function:: void PyStructSequence_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o)
@@ -208,16 +216,17 @@ type.
208216
:c:func:`PyTuple_SET_ITEM`, this should only be used to fill in brand new
209217
instances.
210218
219+
Bounds checking is performed as an assertion if Python is built in
220+
:ref:`debug mode <debug-build>` or :option:`with assertions <--with-assertions>`.
221+
211222
.. note::
212223
213224
This function "steals" a reference to *o*.
214225
215226
216227
.. c:function:: void PyStructSequence_SET_ITEM(PyObject *p, Py_ssize_t *pos, PyObject *o)
217228
218-
Similar to :c:func:`PyStructSequence_SetItem`, but implemented as a static
219-
inlined function.
229+
Alias to :c:func:`PyStructSequence_SetItem`.
220230
221-
.. note::
222-
223-
This function "steals" a reference to *o*.
231+
.. versionchanged:: 3.13
232+
Now implemented as an alias to :c:func:`PyStructSequence_SetItem`.

Doc/c-api/weakref.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,17 @@ as much as it can.
7474
except when it cannot be destroyed before the last usage of the borrowed
7575
reference.
7676
77+
.. deprecated-removed:: 3.13 3.15
78+
Use :c:func:`PyWeakref_GetRef` instead.
79+
7780
7881
.. c:function:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
7982
8083
Similar to :c:func:`PyWeakref_GetObject`, but does no error checking.
8184
85+
.. deprecated-removed:: 3.13 3.15
86+
Use :c:func:`PyWeakref_GetRef` instead.
87+
8288
8389
.. c:function:: void PyObject_ClearWeakRefs(PyObject *object)
8490

Doc/glossary.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ Glossary
8383

8484
asynchronous context manager
8585
An object which controls the environment seen in an
86-
:keyword:`async with` statement by defining :meth:`__aenter__` and
87-
:meth:`__aexit__` methods. Introduced by :pep:`492`.
86+
:keyword:`async with` statement by defining :meth:`~object.__aenter__` and
87+
:meth:`~object.__aexit__` methods. Introduced by :pep:`492`.
8888

8989
asynchronous generator
9090
A function which returns an :term:`asynchronous generator iterator`. It
@@ -104,26 +104,26 @@ Glossary
104104
An object created by a :term:`asynchronous generator` function.
105105

106106
This is an :term:`asynchronous iterator` which when called using the
107-
:meth:`__anext__` method returns an awaitable object which will execute
107+
:meth:`~object.__anext__` method returns an awaitable object which will execute
108108
the body of the asynchronous generator function until the next
109109
:keyword:`yield` expression.
110110

111111
Each :keyword:`yield` temporarily suspends processing, remembering the
112112
location execution state (including local variables and pending
113113
try-statements). When the *asynchronous generator iterator* effectively
114-
resumes with another awaitable returned by :meth:`__anext__`, it
114+
resumes with another awaitable returned by :meth:`~object.__anext__`, it
115115
picks up where it left off. See :pep:`492` and :pep:`525`.
116116

117117
asynchronous iterable
118118
An object, that can be used in an :keyword:`async for` statement.
119119
Must return an :term:`asynchronous iterator` from its
120-
:meth:`__aiter__` method. Introduced by :pep:`492`.
120+
:meth:`~object.__aiter__` method. Introduced by :pep:`492`.
121121

122122
asynchronous iterator
123-
An object that implements the :meth:`__aiter__` and :meth:`__anext__`
124-
methods. ``__anext__`` must return an :term:`awaitable` object.
123+
An object that implements the :meth:`~object.__aiter__` and :meth:`~object.__anext__`
124+
methods. :meth:`~object.__anext__` must return an :term:`awaitable` object.
125125
:keyword:`async for` resolves the awaitables returned by an asynchronous
126-
iterator's :meth:`__anext__` method until it raises a
126+
iterator's :meth:`~object.__anext__` method until it raises a
127127
:exc:`StopAsyncIteration` exception. Introduced by :pep:`492`.
128128

129129
attribute
@@ -140,7 +140,7 @@ Glossary
140140

141141
awaitable
142142
An object that can be used in an :keyword:`await` expression. Can be
143-
a :term:`coroutine` or an object with an :meth:`__await__` method.
143+
a :term:`coroutine` or an object with an :meth:`~object.__await__` method.
144144
See also :pep:`492`.
145145

146146
BDFL

Doc/library/ast.rst

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,102 @@ Node classes
146146
Snakes <https://greentreesnakes.readthedocs.io/en/latest/>`__ project and
147147
all its contributors.
148148

149+
150+
.. _ast-root-nodes:
151+
152+
Root nodes
153+
^^^^^^^^^^
154+
155+
.. class:: Module(body, type_ignores)
156+
157+
A Python module, as with :ref:`file input <file-input>`.
158+
Node type generated by :func:`ast.parse` in the default ``"exec"`` *mode*.
159+
160+
*body* is a :class:`list` of the module's :ref:`ast-statements`.
161+
162+
*type_ignores* is a :class:`list` of the module's type ignore comments;
163+
see :func:`ast.parse` for more details.
164+
165+
.. doctest::
166+
167+
>>> print(ast.dump(ast.parse('x = 1'), indent=4))
168+
Module(
169+
body=[
170+
Assign(
171+
targets=[
172+
Name(id='x', ctx=Store())],
173+
value=Constant(value=1))],
174+
type_ignores=[])
175+
176+
177+
.. class:: Expression(body)
178+
179+
A single Python :ref:`expression input <expression-input>`.
180+
Node type generated by :func:`ast.parse` when *mode* is ``"eval"``.
181+
182+
*body* is a single node,
183+
one of the :ref:`expression types <ast-expressions>`.
184+
185+
.. doctest::
186+
187+
>>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))
188+
Expression(
189+
body=Constant(value=123))
190+
191+
192+
.. class:: Interactive(body)
193+
194+
A single :ref:`interactive input <interactive>`, like in :ref:`tut-interac`.
195+
Node type generated by :func:`ast.parse` when *mode* is ``"single"``.
196+
197+
*body* is a :class:`list` of :ref:`statement nodes <ast-statements>`.
198+
199+
.. doctest::
200+
201+
>>> print(ast.dump(ast.parse('x = 1; y = 2', mode='single'), indent=4))
202+
Interactive(
203+
body=[
204+
Assign(
205+
targets=[
206+
Name(id='x', ctx=Store())],
207+
value=Constant(value=1)),
208+
Assign(
209+
targets=[
210+
Name(id='y', ctx=Store())],
211+
value=Constant(value=2))])
212+
213+
214+
.. class:: FunctionType(argtypes, returns)
215+
216+
A representation of an old-style type comments for functions,
217+
as Python versions prior to 3.5 didn't support :pep:`484` annotations.
218+
Node type generated by :func:`ast.parse` when *mode* is ``"func_type"``.
219+
220+
Such type comments would look like this::
221+
222+
def sum_two_number(a, b):
223+
# type: (int, int) -> int
224+
return a + b
225+
226+
*argtypes* is a :class:`list` of :ref:`expression nodes <ast-expressions>`.
227+
228+
*returns* is a single :ref:`expression node <ast-expressions>`.
229+
230+
.. doctest::
231+
232+
>>> print(ast.dump(ast.parse('(int, str) -> List[int]', mode='func_type'), indent=4))
233+
FunctionType(
234+
argtypes=[
235+
Name(id='int', ctx=Load()),
236+
Name(id='str', ctx=Load())],
237+
returns=Subscript(
238+
value=Name(id='List', ctx=Load()),
239+
slice=Name(id='int', ctx=Load()),
240+
ctx=Load()))
241+
242+
.. versionadded:: 3.8
243+
244+
149245
Literals
150246
^^^^^^^^
151247

@@ -344,6 +440,8 @@ Variables
344440
type_ignores=[])
345441

346442

443+
.. _ast-expressions:
444+
347445
Expressions
348446
^^^^^^^^^^^
349447

@@ -735,6 +833,9 @@ Comprehensions
735833
ifs=[],
736834
is_async=1)]))
737835

836+
837+
.. _ast-statements:
838+
738839
Statements
739840
^^^^^^^^^^
740841

Doc/library/asyncio-eventloop.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,9 @@ TLS Upgrade
895895
object only because the coder caches *protocol*-side data and sporadically
896896
exchanges extra TLS session packets with *transport*.
897897

898+
In some situations (e.g. when the passed transport is already closing) this
899+
may return ``None``.
900+
898901
Parameters:
899902

900903
* *transport* and *protocol* instances that methods like

0 commit comments

Comments
 (0)