Skip to content

Commit 98d1566

Browse files
Pull in main
2 parents e5027c2 + c00dcf0 commit 98d1566

File tree

110 files changed

+5360
-3966
lines changed

Some content is hidden

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

110 files changed

+5360
-3966
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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ jobs:
7272
- name: 'Build known-good files in nit-picky mode'
7373
run: |
7474
# Mark files that must pass nit-picky
75-
touch Doc/whatsnew/3.12.rst
76-
touch Doc/library/sqlite3.rst
75+
python Doc/tools/touch-clean-files.py
7776
# Build docs with the '-n' (nit-picky) option, convert warnings to errors (-W)
7877
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n -W --keep-going" html 2>&1
7978

Doc/howto/enum.rst

Lines changed: 6 additions & 0 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
----------------------------------------------

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/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.

Doc/library/enum.rst

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,8 @@ Module Contents
141141
:func:`global_enum`
142142

143143
Modify the :class:`str() <str>` and :func:`repr` of an enum
144-
to show its members as belonging to the module instead of its class.
145-
Should only be used if the enum members will be exported to the
146-
module global namespace.
144+
to show its members as belonging to the module instead of its class,
145+
and export the enum members to the global namespace.
147146

148147
:func:`show_flag_values`
149148

@@ -170,6 +169,27 @@ Data Types
170169
final *enum*, as well as creating the enum members, properly handling
171170
duplicates, providing iteration over the enum class, etc.
172171

172+
.. method:: EnumType.__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
173+
174+
This method is called in two different ways:
175+
176+
* to look up an existing member:
177+
178+
:cls: The enum class being called.
179+
:value: The value to lookup.
180+
181+
* to use the ``cls`` enum to create a new enum (only if the existing enum
182+
does not have any members):
183+
184+
:cls: The enum class being called.
185+
:value: The name of the new Enum to create.
186+
:names: The names/values of the members for the new Enum.
187+
:module: The name of the module the new Enum is created in.
188+
:qualname: The actual location in the module where this Enum can be found.
189+
:type: A mix-in type for the new Enum.
190+
:start: The first integer value for the Enum (used by :class:`auto`).
191+
:boundary: How to handle out-of-range values from bit operations (:class:`Flag` only).
192+
173193
.. method:: EnumType.__contains__(cls, member)
174194

175195
Returns ``True`` if member belongs to the ``cls``::
@@ -255,26 +275,6 @@ Data Types
255275
names will also be removed from the completed enumeration. See
256276
:ref:`TimePeriod <enum-time-period>` for an example.
257277

258-
.. method:: Enum.__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
259-
260-
This method is called in two different ways:
261-
262-
* to look up an existing member:
263-
264-
:cls: The enum class being called.
265-
:value: The value to lookup.
266-
267-
* to use the ``cls`` enum to create a new enum:
268-
269-
:cls: The enum class being called.
270-
:value: The name of the new Enum to create.
271-
:names: The names/values of the members for the new Enum.
272-
:module: The name of the module the new Enum is created in.
273-
:qualname: The actual location in the module where this Enum can be found.
274-
:type: A mix-in type for the new Enum.
275-
:start: The first integer value for the Enum (used by :class:`auto`).
276-
:boundary: How to handle out-of-range values from bit operations (:class:`Flag` only).
277-
278278
.. method:: Enum.__dir__(self)
279279

280280
Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and
@@ -728,7 +728,6 @@ Data Types
728728
.. attribute:: EJECT
729729

730730
Out-of-range values lose their *Flag* membership and revert to :class:`int`.
731-
This is the default for :class:`IntFlag`::
732731

733732
>>> from enum import Flag, EJECT, auto
734733
>>> class EjectFlag(Flag, boundary=EJECT):
@@ -741,8 +740,8 @@ Data Types
741740

742741
.. attribute:: KEEP
743742

744-
Out-of-range values are kept, and the *Flag* membership is kept. This is
745-
used for some stdlib flags::
743+
Out-of-range values are kept, and the *Flag* membership is kept.
744+
This is the default for :class:`IntFlag`::
746745

747746
>>> from enum import Flag, KEEP, auto
748747
>>> class KeepFlag(Flag, boundary=KEEP):

Doc/library/gc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ values but should not rebind them):
251251
are printed.
252252

253253
.. versionchanged:: 3.4
254-
Following :pep:`442`, objects with a :meth:`__del__` method don't end
254+
Following :pep:`442`, objects with a :meth:`~object.__del__` method don't end
255255
up in :attr:`gc.garbage` anymore.
256256

257257
.. data:: callbacks

Doc/library/profile.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ the following::
8282

8383
The first line indicates that 214 calls were monitored. Of those calls, 207
8484
were :dfn:`primitive`, meaning that the call was not induced via recursion. The
85-
next line: ``Ordered by: cumulative name``, indicates that the text string in the
85+
next line: ``Ordered by: cumulative time``, indicates that the text string in the
8686
far right column was used to sort the output. The column headings include:
8787

8888
ncalls

Doc/library/string.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ non-empty format specification typically modifies the result.
310310
The general form of a *standard format specifier* is:
311311

312312
.. productionlist:: format-spec
313-
format_spec: [[`fill`]`align`][`sign`][z][#][0][`width`][`grouping_option`][.`precision`][`type`]
313+
format_spec: [[`fill`]`align`][`sign`]["z"]["#"]["0"][`width`][`grouping_option`]["." `precision`][`type`]
314314
fill: <any character>
315315
align: "<" | ">" | "=" | "^"
316316
sign: "+" | "-" | " "

Doc/library/test.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,21 @@ The :mod:`test.support.warnings_helper` module provides support for warnings tes
16911691
.. versionadded:: 3.10
16921692

16931693

1694+
.. function:: ignore_warnings(*, category)
1695+
1696+
Suppress warnings that are instances of *category*,
1697+
which must be :exc:`Warning` or a subclass.
1698+
Roughly equivalent to :func:`warnings.catch_warnings`
1699+
with :meth:`warnings.simplefilter('ignore', category=category) <warnings.simplefilter>`.
1700+
For example::
1701+
1702+
@warning_helper.ignore_warnings(category=DeprecationWarning)
1703+
def test_suppress_warning():
1704+
# do something
1705+
1706+
.. versionadded:: 3.8
1707+
1708+
16941709
.. function:: check_no_resource_warning(testcase)
16951710

16961711
Context manager to check that no :exc:`ResourceWarning` was raised. You

Doc/library/typing.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,17 @@ For a summary of deprecated features and a deprecation timeline, please see
4141

4242
.. seealso::
4343

44+
For a quick overview of type hints, refer to
45+
`this cheat sheet <https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html>`_.
46+
47+
The "Type System Reference" section of https://mypy.readthedocs.io/ -- since
48+
the Python typing system is standardised via PEPs, this reference should
49+
broadly apply to most Python type checkers, although some parts may still be
50+
specific to mypy.
51+
4452
The documentation at https://typing.readthedocs.io/ serves as useful reference
4553
for type system features, useful typing related tools and typing best practices.
4654

47-
4855
.. _relevant-peps:
4956

5057
Relevant PEPs
@@ -1591,6 +1598,15 @@ These are not used in annotations. They are building blocks for creating generic
15911598
import threading
15921599
assert isinstance(threading.Thread(name='Bob'), Named)
15931600

1601+
.. versionchanged:: 3.12
1602+
The internal implementation of :func:`isinstance` checks against
1603+
runtime-checkable protocols now uses :func:`inspect.getattr_static`
1604+
to look up attributes (previously, :func:`hasattr` was used).
1605+
As a result, some objects which used to be considered instances
1606+
of a runtime-checkable protocol may no longer be considered instances
1607+
of that protocol on Python 3.12+, and vice versa.
1608+
Most users are unlikely to be affected by this change.
1609+
15941610
.. note::
15951611

15961612
:func:`!runtime_checkable` will check only the presence of the required

0 commit comments

Comments
 (0)