Skip to content

Commit 4d91ff9

Browse files
authored
Merge branch 'main' into fstring-grammar-rebased-after-sprint
2 parents aba4fc9 + 52bc2e7 commit 4d91ff9

File tree

303 files changed

+10467
-7688
lines changed

Some content is hidden

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

303 files changed

+10467
-7688
lines changed

.devcontainer/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM docker.io/library/fedora:37
2+
3+
ENV CC=clang
4+
5+
ENV WASI_SDK_VERSION=19
6+
ENV WASI_SDK_PATH=/opt/wasi-sdk
7+
8+
ENV WASMTIME_HOME=/opt/wasmtime
9+
ENV WASMTIME_VERSION=7.0.0
10+
ENV WASMTIME_CPU_ARCH=x86_64
11+
12+
RUN dnf -y --nodocs install git clang xz python3-blurb dnf-plugins-core && \
13+
dnf -y --nodocs builddep python3 && \
14+
dnf -y clean all
15+
16+
RUN mkdir ${WASI_SDK_PATH} && \
17+
curl --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-linux.tar.gz | \
18+
tar --strip-components 1 --directory ${WASI_SDK_PATH} --extract --gunzip
19+
20+
RUN mkdir --parents ${WASMTIME_HOME} && \
21+
curl --location "https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasmtime-v${WASMTIME_VERSION}-${WASMTIME_CPU_ARCH}-linux.tar.xz" | \
22+
xz --decompress | \
23+
tar --strip-components 1 --directory ${WASMTIME_HOME} -x && \
24+
ln -s ${WASMTIME_HOME}/wasmtime /usr/local/bin

.devcontainer/devcontainer.json

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"build": {
3+
"dockerfile": "Dockerfile"
4+
},
5+
"onCreateCommand": [
6+
// Install common tooling.
7+
"dnf",
8+
"install",
9+
"-y",
10+
"which",
11+
"zsh",
12+
"fish"
13+
],
14+
"updateContentCommand": {
15+
// Using the shell for `nproc` usage.
16+
"python": "./configure --config-cache --with-pydebug && make -s -j `nproc`",
17+
"docs": [
18+
"make",
19+
"--directory",
20+
"Doc",
21+
"venv",
22+
"html"
23+
]
24+
},
25+
"customizations": {
26+
"vscode": {
27+
"extensions": [
28+
// Highlighting for Parser/Python.asdl.
29+
"brettcannon.zephyr-asdl",
30+
// Highlighting for configure.ac.
31+
"maelvalais.autoconf",
32+
// C auto-complete.
33+
"ms-vscode.cpptools",
34+
// To view built docs.
35+
"ms-vscode.live-server"
36+
// https://github.com/microsoft/vscode-python/issues/18073
37+
// "ms-python.python"
38+
],
39+
"settings": {
40+
"C_Cpp.default.compilerPath": "/usr/bin/clang",
41+
"C_Cpp.default.cStandard": "c11",
42+
"C_Cpp.default.defines": [
43+
"CONFIG_64",
44+
"Py_BUILD_CORE"
45+
],
46+
"C_Cpp.default.includePath": [
47+
"${workspaceFolder}/*",
48+
"${workspaceFolder}/Include/**"
49+
],
50+
// https://github.com/microsoft/vscode-cpptools/issues/10732
51+
"C_Cpp.errorSquiggles": "disabled",
52+
"editor.insertSpaces": true,
53+
"editor.rulers": [
54+
80
55+
],
56+
"editor.tabSize": 4,
57+
"editor.trimAutoWhitespace": true,
58+
"files.associations": {
59+
"*.h": "c"
60+
},
61+
"files.encoding": "utf8",
62+
"files.eol": "\n",
63+
"files.insertFinalNewline": true,
64+
"files.trimTrailingWhitespace": true,
65+
"python.analysis.diagnosticSeverityOverrides": {
66+
// Complains about shadowing the stdlib w/ the stdlib.
67+
"reportShadowedImports": "none",
68+
// Doesn't like _frozen_importlib.
69+
"reportMissingImports": "none"
70+
},
71+
"python.analysis.extraPaths": [
72+
"Lib"
73+
],
74+
"python.defaultInterpreterPath": "./python",
75+
"[restructuredtext]": {
76+
"editor.tabSize": 3
77+
}
78+
}
79+
}
80+
}
81+
}

.github/workflows/doc.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@ 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+
python Doc/tools/touch-clean-files.py
76+
# Build docs with the '-n' (nit-picky) option, convert warnings to errors (-W)
77+
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n -W --keep-going" html 2>&1
78+
5679
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
5780
doctest:
5881
name: 'Doctest'

Doc/c-api/exceptions.rst

Lines changed: 1 addition & 1 deletion
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/object.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@ Object Protocol
179179
If *o1* and *o2* are the same object, :c:func:`PyObject_RichCompareBool`
180180
will always return ``1`` for :const:`Py_EQ` and ``0`` for :const:`Py_NE`.
181181
182+
.. c:function:: PyObject* PyObject_Format(PyObject *obj, PyObject *format_spec)
183+
184+
Format *obj* using *format_spec*. This is equivalent to the Python
185+
expression ``format(obj, format_spec)``.
186+
187+
*format_spec* may be ``NULL``. In this case the call is equivalent
188+
to ``format(obj)``.
189+
Returns the formatted string on success, ``NULL`` on failure.
190+
182191
.. c:function:: PyObject* PyObject_Repr(PyObject *o)
183192
184193
.. index:: builtin: repr

Doc/c-api/weakref.rst

Lines changed: 10 additions & 0 deletions
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/howto/enum.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ The values are chosen by :func:`_generate_next_value_`, which can be
284284
overridden::
285285

286286
>>> class AutoName(Enum):
287+
... @staticmethod
287288
... def _generate_next_value_(name, start, count, last_values):
288289
... return name
289290
...
@@ -372,6 +373,11 @@ below)::
372373
>>> Color.BLUE == 2
373374
False
374375

376+
.. warning::
377+
378+
It is possible to reload modules -- if a reloaded module contains
379+
enums, they will be recreated, and the new members may not
380+
compare identical/equal to the original members.
375381

376382
Allowed members and attributes of enumerations
377383
----------------------------------------------
@@ -982,12 +988,11 @@ but remain normal attributes.
982988
""""""""""""""""""""
983989

984990
Enum members are instances of their enum class, and are normally accessed as
985-
``EnumClass.member``. In Python versions starting with ``3.5`` you could access
986-
members from other members -- this practice is discouraged, is deprecated
987-
in ``3.12``, and will be removed in ``3.14``.
991+
``EnumClass.member``. In certain situations, such as writing custom enum
992+
behavior, being able to access one member directly from another is useful,
993+
and is supported.
988994

989995
.. versionchanged:: 3.5
990-
.. versionchanged:: 3.12
991996

992997

993998
Creating members that are mixed with other data types

Doc/howto/logging-cookbook.rst

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -340,23 +340,27 @@ adding a ``filters`` section parallel to ``formatters`` and ``handlers``:
340340

341341
.. code-block:: json
342342
343-
"filters": {
344-
"warnings_and_below": {
345-
"()" : "__main__.filter_maker",
346-
"level": "WARNING"
343+
{
344+
"filters": {
345+
"warnings_and_below": {
346+
"()" : "__main__.filter_maker",
347+
"level": "WARNING"
348+
}
347349
}
348350
}
349351
350352
and changing the section on the ``stdout`` handler to add it:
351353

352354
.. code-block:: json
353355
354-
"stdout": {
355-
"class": "logging.StreamHandler",
356-
"level": "INFO",
357-
"formatter": "simple",
358-
"stream": "ext://sys.stdout",
359-
"filters": ["warnings_and_below"]
356+
{
357+
"stdout": {
358+
"class": "logging.StreamHandler",
359+
"level": "INFO",
360+
"formatter": "simple",
361+
"stream": "ext://sys.stdout",
362+
"filters": ["warnings_and_below"]
363+
}
360364
}
361365
362366
A filter is just a function, so we can define the ``filter_maker`` (a factory

Doc/library/asyncio-task.rst

Lines changed: 29 additions & 18 deletions
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/codeop.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ module instead.
1919

2020
There are two parts to this job:
2121

22-
#. Being able to tell if a line of input completes a Python statement: in
22+
#. Being able to tell if a line of input completes a Python statement: in
2323
short, telling whether to print '``>>>``' or '``...``' next.
2424

25-
#. Remembering which future statements the user has entered, so subsequent
25+
#. Remembering which future statements the user has entered, so subsequent
2626
input can be compiled with these in effect.
2727

2828
The :mod:`codeop` module provides a way of doing each of these things, and a way
@@ -33,19 +33,19 @@ To do just the former:
3333
.. function:: compile_command(source, filename="<input>", symbol="single")
3434

3535
Tries to compile *source*, which should be a string of Python code and return a
36-
code object if *source* is valid Python code. In that case, the filename
36+
code object if *source* is valid Python code. In that case, the filename
3737
attribute of the code object will be *filename*, which defaults to
38-
``'<input>'``. Returns ``None`` if *source* is *not* valid Python code, but is a
38+
``'<input>'``. Returns ``None`` if *source* is *not* valid Python code, but is a
3939
prefix of valid Python code.
4040

4141
If there is a problem with *source*, an exception will be raised.
4242
:exc:`SyntaxError` is raised if there is invalid Python syntax, and
4343
:exc:`OverflowError` or :exc:`ValueError` if there is an invalid literal.
4444

4545
The *symbol* argument determines whether *source* is compiled as a statement
46-
(``'single'``, the default), as a sequence of statements (``'exec'``) or
46+
(``'single'``, the default), as a sequence of :term:`statement` (``'exec'``) or
4747
as an :term:`expression` (``'eval'``). Any other value will
48-
cause :exc:`ValueError` to be raised.
48+
cause :exc:`ValueError` to be raised.
4949

5050
.. note::
5151

@@ -69,5 +69,5 @@ To do just the former:
6969

7070
Instances of this class have :meth:`__call__` methods identical in signature to
7171
:func:`compile_command`; the difference is that if the instance compiles program
72-
text containing a ``__future__`` statement, the instance 'remembers' and
72+
text containing a :mod:`__future__` statement, the instance 'remembers' and
7373
compiles all subsequent program texts with the statement in force.

0 commit comments

Comments
 (0)