Skip to content

Commit 29cdbee

Browse files
authored
Merge branch 'main' into pythongh-81079-glob-case-sensitive-arg-2
2 parents e386a54 + 2cdc518 commit 29cdbee

File tree

117 files changed

+2225
-2044
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

+2225
-2044
lines changed

.github/workflows/doc.yml

+24
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,30 @@ jobs:
5353
- name: 'Build HTML documentation'
5454
run: make -C Doc/ SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" html
5555

56+
# Add pull request annotations for Sphinx nitpicks (missing references)
57+
- name: 'Get list of changed files'
58+
id: changed_files
59+
uses: Ana06/[email protected]
60+
with:
61+
filter: "Doc/**"
62+
- name: 'Build changed files in nit-picky mode'
63+
continue-on-error: true
64+
run: |
65+
# Mark files the pull request modified
66+
touch ${{ steps.changed_files.outputs.added_modified }}
67+
# Build docs with the '-n' (nit-picky) option; convert warnings to annotations
68+
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n --keep-going" html 2>&1 |
69+
python Doc/tools/warnings-to-gh-actions.py
70+
71+
# Ensure some files always pass Sphinx nit-picky mode (no missing references)
72+
- name: 'Build known-good files in nit-picky mode'
73+
run: |
74+
# Mark files that must pass nit-picky
75+
touch Doc/whatsnew/3.12.rst
76+
touch Doc/library/sqlite3.rst
77+
# Build docs with the '-n' (nit-picky) option, convert warnings to errors (-W)
78+
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n -W --keep-going" html 2>&1
79+
5680
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
5781
doctest:
5882
name: 'Doctest'

Doc/c-api/exceptions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Printing and clearing
8686
8787
An exception must be set when calling this function.
8888
89-
.. c:function: void PyErr_DisplayException(PyObject *exc)
89+
.. c:function:: void PyErr_DisplayException(PyObject *exc)
9090
9191
Print the standard traceback display of ``exc`` to ``sys.stderr``, including
9292
chained exceptions and notes.

Doc/c-api/weakref.rst

+10
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,13 @@ as much as it can.
6767
.. c:function:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
6868
6969
Similar to :c:func:`PyWeakref_GetObject`, but does no error checking.
70+
71+
72+
.. c:function:: void PyObject_ClearWeakRefs(PyObject *object)
73+
74+
This function is called by the :c:member:`~PyTypeObject.tp_dealloc` handler
75+
to clear weak references.
76+
77+
This iterates through the weak references for *object* and calls callbacks
78+
for those references which have one. It returns when all callbacks have
79+
been attempted.

Doc/library/asyncio-task.rst

+29-18
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,17 @@ in the task at the next opportunity.
300300
It is recommended that coroutines use ``try/finally`` blocks to robustly
301301
perform clean-up logic. In case :exc:`asyncio.CancelledError`
302302
is explicitly caught, it should generally be propagated when
303-
clean-up is complete. Most code can safely ignore :exc:`asyncio.CancelledError`.
303+
clean-up is complete. :exc:`asyncio.CancelledError` directly subclasses
304+
:exc:`BaseException` so most code will not need to be aware of it.
304305

305306
The asyncio components that enable structured concurrency, like
306307
:class:`asyncio.TaskGroup` and :func:`asyncio.timeout`,
307308
are implemented using cancellation internally and might misbehave if
308309
a coroutine swallows :exc:`asyncio.CancelledError`. Similarly, user code
309-
should not call :meth:`uncancel <asyncio.Task.uncancel>`.
310+
should not generally call :meth:`uncancel <asyncio.Task.uncancel>`.
311+
However, in cases when suppressing :exc:`asyncio.CancelledError` is
312+
truly desired, it is necessary to also call ``uncancel()`` to completely
313+
remove the cancellation state.
310314

311315
.. _taskgroups:
312316

@@ -620,32 +624,26 @@ Timeouts
620624
The context manager produced by :func:`asyncio.timeout` can be
621625
rescheduled to a different deadline and inspected.
622626

623-
.. class:: Timeout()
627+
.. class:: Timeout(when)
624628

625629
An :ref:`asynchronous context manager <async-context-managers>`
626-
that limits time spent inside of it.
630+
for cancelling overdue coroutines.
627631

628-
.. versionadded:: 3.11
632+
``when`` should be an absolute time at which the context should time out,
633+
as measured by the event loop's clock:
634+
635+
- If ``when`` is ``None``, the timeout will never trigger.
636+
- If ``when < loop.time()``, the timeout will trigger on the next
637+
iteration of the event loop.
629638

630639
.. method:: when() -> float | None
631640

632641
Return the current deadline, or ``None`` if the current
633642
deadline is not set.
634643

635-
The deadline is a float, consistent with the time returned by
636-
:meth:`loop.time`.
637-
638644
.. method:: reschedule(when: float | None)
639645

640-
Change the time the timeout will trigger.
641-
642-
If *when* is ``None``, any current deadline will be removed, and the
643-
context manager will wait indefinitely.
644-
645-
If *when* is a float, it is set as the new deadline.
646-
647-
if *when* is in the past, the timeout will trigger on the next
648-
iteration of the event loop.
646+
Reschedule the timeout.
649647

650648
.. method:: expired() -> bool
651649

@@ -962,6 +960,13 @@ Introspection
962960
.. versionadded:: 3.7
963961

964962

963+
.. function:: iscoroutine(obj)
964+
965+
Return ``True`` if *obj* is a coroutine object.
966+
967+
.. versionadded:: 3.4
968+
969+
965970
Task Object
966971
===========
967972

@@ -1148,7 +1153,9 @@ Task Object
11481153
Therefore, unlike :meth:`Future.cancel`, :meth:`Task.cancel` does
11491154
not guarantee that the Task will be cancelled, although
11501155
suppressing cancellation completely is not common and is actively
1151-
discouraged.
1156+
discouraged. Should the coroutine nevertheless decide to suppress
1157+
the cancellation, it needs to call :meth:`Task.uncancel` in addition
1158+
to catching the exception.
11521159

11531160
.. versionchanged:: 3.9
11541161
Added the *msg* parameter.
@@ -1238,6 +1245,10 @@ Task Object
12381245
with :meth:`uncancel`. :class:`TaskGroup` context managers use
12391246
:func:`uncancel` in a similar fashion.
12401247

1248+
If end-user code is, for some reason, suppresing cancellation by
1249+
catching :exc:`CancelledError`, it needs to call this method to remove
1250+
the cancellation state.
1251+
12411252
.. method:: cancelling()
12421253

12431254
Return the number of pending cancellation requests to this Task, i.e.,

Doc/library/ctypes.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ that they can be converted to the required C data type::
375375

376376
.. _ctypes-calling-variadic-functions:
377377

378-
Calling varadic functions
379-
^^^^^^^^^^^^^^^^^^^^^^^^^
378+
Calling variadic functions
379+
^^^^^^^^^^^^^^^^^^^^^^^^^^
380380

381381
On a lot of platforms calling variadic functions through ctypes is exactly the same
382382
as calling functions with a fixed number of parameters. On some platforms, and in
@@ -508,7 +508,7 @@ a string pointer and a char, and returns a pointer to a string::
508508

509509
If you want to avoid the ``ord("x")`` calls above, you can set the
510510
:attr:`argtypes` attribute, and the second argument will be converted from a
511-
single character Python bytes object into a C char::
511+
single character Python bytes object into a C char:
512512

513513
.. doctest::
514514

Doc/library/dis.rst

-33
Original file line numberDiff line numberDiff line change
@@ -1042,15 +1042,6 @@ iterations of the loop.
10421042
``cmp_op[opname]``.
10431043

10441044

1045-
.. opcode:: COMPARE_AND_BRANCH (opname)
1046-
1047-
Compares the top two values on the stack, popping them, then branches.
1048-
The direction and offset of the jump is embedded as a ``POP_JUMP_IF_TRUE``
1049-
or ``POP_JUMP_IF_FALSE`` instruction immediately following the cache.
1050-
1051-
.. versionadded:: 3.12
1052-
1053-
10541045
.. opcode:: IS_OP (invert)
10551046

10561047
Performs ``is`` comparison, or ``is not`` if ``invert`` is 1.
@@ -1152,30 +1143,6 @@ iterations of the loop.
11521143
.. versionchanged:: 3.12
11531144
This is no longer a pseudo-instruction.
11541145

1155-
1156-
.. opcode:: JUMP_IF_TRUE_OR_POP (delta)
1157-
1158-
If ``STACK[-1]`` is true, increments the bytecode counter by *delta* and leaves
1159-
``STACK[-1]`` on the stack. Otherwise (``STACK[-1]`` is false), ``STACK[-1]``
1160-
is popped.
1161-
1162-
.. versionadded:: 3.1
1163-
1164-
.. versionchanged:: 3.11
1165-
The oparg is now a relative delta rather than an absolute target.
1166-
1167-
.. opcode:: JUMP_IF_FALSE_OR_POP (delta)
1168-
1169-
If ``STACK[-1]`` is false, increments the bytecode counter by *delta* and leaves
1170-
``STACK[-1]`` on the stack. Otherwise (``STACK[-1]`` is true), ``STACK[-1]`` is
1171-
popped.
1172-
1173-
.. versionadded:: 3.1
1174-
1175-
.. versionchanged:: 3.11
1176-
The oparg is now a relative delta rather than an absolute target.
1177-
1178-
11791146
.. opcode:: FOR_ITER (delta)
11801147

11811148
``STACK[-1]`` is an :term:`iterator`. Call its :meth:`~iterator.__next__` method.

Doc/library/exceptions.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,8 @@ their subgroups based on the types of the contained exceptions.
948948
these fields do not need to be updated by :meth:`derive`. ::
949949

950950
>>> class MyGroup(ExceptionGroup):
951-
... def derive(self, exc):
952-
... return MyGroup(self.message, exc)
951+
... def derive(self, excs):
952+
... return MyGroup(self.message, excs)
953953
...
954954
>>> e = MyGroup("eg", [ValueError(1), TypeError(2)])
955955
>>> e.add_note("a note")

Doc/library/gzip.rst

+6
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ The module defines the following items:
143143
:func:`time.time` and the :attr:`~os.stat_result.st_mtime` attribute of
144144
the object returned by :func:`os.stat`.
145145

146+
.. attribute:: name
147+
148+
The path to the gzip file on disk, as a :class:`str` or :class:`bytes`.
149+
Equivalent to the output of :func:`os.fspath` on the original input path,
150+
with no other normalization, resolution or expansion.
151+
146152
.. versionchanged:: 3.1
147153
Support for the :keyword:`with` statement was added, along with the
148154
*mtime* constructor argument and :attr:`mtime` attribute.

Doc/library/inspect.rst

+4
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ Retrieving source code
574574
object and the line number indicates where in the original source file the first
575575
line of code was found. An :exc:`OSError` is raised if the source code cannot
576576
be retrieved.
577+
A :exc:`TypeError` is raised if the object is a built-in module, class, or
578+
function.
577579

578580
.. versionchanged:: 3.3
579581
:exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the
@@ -586,6 +588,8 @@ Retrieving source code
586588
class, method, function, traceback, frame, or code object. The source code is
587589
returned as a single string. An :exc:`OSError` is raised if the source code
588590
cannot be retrieved.
591+
A :exc:`TypeError` is raised if the object is a built-in module, class, or
592+
function.
589593

590594
.. versionchanged:: 3.3
591595
:exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the

Doc/library/itertools.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ which incur interpreter overhead.
936936
n = quotient
937937
if n == 1:
938938
return
939-
if n >= 2:
939+
if n > 1:
940940
yield n
941941

942942
def flatten(list_of_lists):

Doc/library/logging.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -813,8 +813,9 @@ wire).
813813
:type lineno: int
814814

815815
:param msg: The event description message,
816-
which can be a %-format string with placeholders for variable data.
817-
:type msg: str
816+
which can be a %-format string with placeholders for variable data,
817+
or an arbitrary object (see :ref:`arbitrary-object-messages`).
818+
:type msg: typing.Any
818819

819820
:param args: Variable data to merge into the *msg* argument
820821
to obtain the event description.

0 commit comments

Comments
 (0)