8000 Merge branch 'main' into gh-105623 · zhatt/cpython@a677f11 · GitHub
[go: up one dir, main page]

Skip to content

Commit a677f11

Browse files
authored
Merge branch 'main' into pythongh-105623
2 parents 84ad7d8 + 6e40ee6 commit a677f11

Some content is hidden

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

67 files changed

+1420
-1080
lines changed

.github/workflows/reusable-docs.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ jobs:
2828
cache-dependency-path: 'Doc/requirements.txt'
2929
- name: 'Install build dependencies'
3030
run: make -C Doc/ venv
31-
- name: 'Check documentation'
32-
run: make -C Doc/ check
3331
- name: 'Build HTML documentation'
3432
run: make -C Doc/ SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" html
3533

@@ -59,8 +57,6 @@ jobs:
5957
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n -W --keep-going" html 2>&1
6058
6159
# This build doesn't use problem matchers or check annotations
62-
# It also does not run 'make check', as sphinx-lint is not installed into the
63-
# environment.
6460
build_doc_oldest_supported_sphinx:
6561
name: 'Docs (Oldest Sphinx)'
6662
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ repos:
55
- id: check-yaml
66
- id: trailing-whitespace
77
types_or: [c, python, rst]
8+
9+
- repo: https://github.com/sphinx-contrib/sphinx-lint
10+
rev: v0.6.7
11+
hooks:
12+
- id: sphinx-lint
13+
args: [--enable=default-role]
14+
files: ^Doc/
15+
types: [rst]

Doc/Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,9 @@ dist:
216216
rm dist/python-$(DISTVERSION)-docs-texinfo.tar
217217

218218
.PHONY: check
219-
check:
220-
# Check the docs and NEWS files with sphinx-lint.
221-
# Ignore the tools and venv dirs and check that the default role is not used.
222-
$(SPHINXLINT) -i tools -i $(VENVDIR) --enable default-role
223-
$(SPHINXLINT) --enable default-role ../Misc/NEWS.d/next/
219+
check: venv
220+
$(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit
221+
$(VENVDIR)/bin/python3 -m pre_commit run --all-files
224222

225223
.PHONY: serve
226224
serve:

Doc/c-api/import.rst

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,40 @@ Importing Modules
9898
an exception set on failure (the module still exists in this case).
9999
100100
101-
.. c:function:: PyObject* PyImport_AddModuleObject(PyObject *name)
101+
.. c:function:: PyObject* PyImport_AddModuleRef(const char *name)
102+
103+
Return the module object corresponding to a module name.
104+
105+
The *name* argument may be of the form ``package.module``. First check the
106+
modules dictionary if there's one there, and if not, create a new one and
107+
insert it in the modules dictionary.
108+
109+
Return a :term:`strong reference` to the module on success. Return ``NULL``
110+
with an exception set on failure.
102111
103-
Return the module object corresponding to a module name. The *name* argument
104-
may be of the form ``package.module``. First check the modules dictionary if
105-
there's one there, and if not, create a new one and insert it in the modules
106-
dictionary. Return ``NULL`` with an exception set on failure.
112+
The module name *name* is decoded from UTF-8.
107113
108-
.. note::
114+
This function does not load or import the module; if the module wasn't
115+
already loaded, you will get an empty module object. Use
116+
:c:func:`PyImport_ImportModule` or one of its variants to import a module.
117+
Package structures implied by a dotted name for *name* are not created if
118+
not already present.
119+
120+
.. versionadded:: 3.13
121+
122+
123+
.. c:function:: PyObject* PyImport_AddModuleObject(PyObject *name)
109124
110-
This function does not load or import the module; if the module wasn't already
111-
loaded, you will get an empty module object. Use :c:func:`PyImport_ImportModule`
112-
or one of its variants to import a module. Package structures implied by a
113-
dotted name for *name* are not created if not already present.
125+
Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed
126+
reference` and *name* is a Python :class:`str` object.
114127
115128
.. versionadded:: 3.3
116129
117130
118131
.. c:function:: PyObject* PyImport_AddModule(const char *name)
119132
120-
Similar to :c:func:`PyImport_AddModuleObject`, but the name is a UTF-8
121-
encoded string instead of a Unicode object.
133+
Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed
134+
reference`.
122135
123136
124137
.. c:function:: PyObject* PyImport_ExecCodeModule(const char *name, PyObject *co)

Doc/constraints.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,3 @@ sphinxcontrib-serializinghtml<1.2
2323

2424
# Direct dependencies of Jinja2 (Jinja is a dependency of Sphinx, see above)
2525
MarkupSafe<2.2
26-
27-
# Direct dependencies of sphinx-lint
28-
polib<1.3
29-
regex<2024

Doc/data/refcounts.dat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,9 @@ PyCoro_New:PyFrameObject*:frame:0:
974974
PyCoro_New:PyObject*:name:0:
975975
PyCoro_New:PyObject*:qualname:0:
976976

977+
PyImport_AddModuleRef:PyObject*::+1:
978+
PyImport_AddModuleRef:const char*:name::
979+
977980
PyImport_AddModule:PyObject*::0:reference borrowed from sys.modules
978981
PyImport_AddModule:const char*:name::
979982

Doc/data/stable_abi.dat

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/faq/general.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Python versions are numbered "A.B.C" or "A.B":
135135

136136
See :pep:`6` for more information about bugfix releases.
137137

138-
Not all releases are bugfix releases. In the run-up to a new minor release, a
138+
Not all releases are bugfix releases. In the run-up to a new feature release, a
139139
series of development releases are made, denoted as alpha, beta, or release
140140
candidate. Alphas are early releases in which interfaces aren't yet finalized;
141141
it's not unexpected to see an interface change between two alpha releases.
@@ -297,9 +297,9 @@ How stable is Python?
297297

298298
Very stable. New, stable releases have been coming out roughly every 6 to 18
299299
months since 1991, and this seems likely to continue. As of version 3.9,
300-
Python will have a minor new release every 12 months (:pep:`602`).
300+
Python will have a new feature release every 12 months (:pep:`602`).
301301

302-
The developers issue "bugfix" releases of older versions, so the stability of
302+
The developers issue bugfix releases of older versions, so the stability of
303303
existing releases gradually improves. Bugfix releases, indicated by a third
304304
component of the version number (e.g. 3.5.3, 3.6.2), are managed for stability;
305305
only fixes for known problems are included in a bugfix release, and it's

Doc/library/sqlite3.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ PostgreSQL or Oracle.
2929

3030
The :mod:`!sqlite3` module was written by Gerhard Häring. It provides an SQL interface
3131
compliant with the DB-API 2.0 specification described by :pep:`249`, and
32-
requires SQLite 3.7.15 or newer.
32+
requires SQLite 3.15.2 or newer.
3333

3434
This document includes four main sections:
3535

@@ -734,9 +734,6 @@ Connection objects
734734
`deterministic <https://sqlite.org/deterministic.html>`_,
735735
which allows SQLite to perform additional optimizations.
736736

737-
:raises NotSupportedError:
738-
If *deterministic* is used with SQLite versions older than 3.8.3.
739-
740737
.. versionadded:: 3.8
741738
The *deterministic* parameter.
742739

Doc/library/typing.rst

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323

2424
--------------
2525

26-
This module provides runtime support for type hints. The most fundamental
27-
support consists of the types :data:`Any`, :data:`Union`, :data:`Callable`,
28-
:class:`TypeVar`, and :class:`Generic`. For a specification, please see
29-
:pep:`484`. For a simplified introduction to type hints, see :pep:`483`.
26+
This module provides runtime support for type hints. For the original
27+
specification of the typing system, see :pep:`484`. For a simplified
28+
introduction to type hints, see :pep:`483`.
3029

3130

3231
The function below takes and returns a string and is annotated as follows::
@@ -47,16 +46,18 @@ For a summary of deprecated features and a deprecation timeline, please see
4746

4847
.. seealso::
4948

50-
For a quick overview of type hints, refer to
51-
`this cheat sheet <https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html>`_.
49+
`"Typing cheat sheet" <https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html>`_
50+
A quick overview of type hints (hosted at the mypy docs)
5251

53-
The "Type System Reference" section of https://mypy.readthedocs.io/ -- since
54-
the Python typing system is standardised via PEPs, this reference should
55-
broadly apply to most Python type checkers, although some parts may still be
56-
specific to mypy.
52+
"Type System Reference" section of `the mypy docs <https://mypy.readthedocs.io/en/stable/index.html>`_
53+
The Python typing system is standardised via PEPs, so this reference
54+
should broadly apply to most Python type checkers. (Some parts may still
55+
be specific to mypy.)
5756

58-
The documentation at https://typing.readthedocs.io/ serves as useful reference
59-
for type system features, useful typing related tools and typing best practices.
57+
`"Static Typing with Python" <https://typing.readthedocs.io/en/latest/>`_
58+
Type-checker-agnostic documentation written by the community detailing
59+
type system features, useful typing related tools and typing best
60+
practices.
6061

6162
.. _relevant-peps:
6263

@@ -654,33 +655,16 @@ can define new custom protocols to fully enjoy structural subtyping
654655
Module contents
655656
===============
656657

657-
The module defines the following classes, functions and decorators.
658-
659-
.. note::
660-
661-
This module defines several deprecated aliases to pre-existing
662-
standard library classes. These were originally included in the typing
663-
module in order to support parameterizing these generic classes using ``[]``.
664-
However, the aliases became redundant in Python 3.9 when the
665-
corresponding pre-existing classes were enhanced to support ``[]``.
666-
667-
The redundant types are deprecated as of Python 3.9 but no
668-
deprecation warnings are issued by the interpreter.
669-
It is expected that type checkers will flag the deprecated types
670-
when the checked program targets Python 3.9 or newer.
671-
672-
The deprecated types will be removed from the :mod:`typing` module
673-
no sooner than the first Python version released 5 years after the release of Python 3.9.0.
674-
See details in :pep:`585`—*Type Hinting Generics In Standard Collections*.
675-
658+
The ``typing`` module defines the following classes, functions and decorators.
676659

677660
Special typing primitives
678661
-------------------------
679662

680663
Special types
681664
"""""""""""""
682665

683-
These can be used as types in annotations and do not support ``[]``.
666+
These can be used as types in annotations. They do not support subscription
667+
using ``[]``.
684668

685669
.. data:: Any
686670

@@ -890,7 +874,8 @@ These can be used as types in annotations and do not support ``[]``.
890874
Special forms
891875
"""""""""""""
892876

893-
These can be used as types in annotations using ``[]``, each having a unique syntax.
877+
These can be used as types in annotations. They all support subscription using
878+
``[]``, but each has a unique syntax.
894879

895880
.. data:: Tuple
896881

@@ -1471,7 +1456,8 @@ These can be used as types in annotations using ``[]``, each having a unique syn
14711456
Building generic types and type aliases
14721457
"""""""""""""""""""""""""""""""""""""""
14731458

1474-
The following objects are not used directly in annotations. Instead, they are building blocks
1459+
The following classes should not be used directly as annotations.
1460+
Their intended purpose is to be building blocks
14751461
for creating generic types and type aliases.
14761462

14771463
These objects can be created through special syntax
@@ -1962,7 +1948,9 @@ without the dedicated syntax, as documented below.
19621948
Other special directives
19631949
""""""""""""""""""""""""
19641950

1965-
These are not used in annotations. They are building blocks for declaring types.
1951+
These functions and classes should not be used directly as annotations.
1952+
Their intended purpose is to be building blocks for creating and declaring
1953+
types.
19661954

19671955
.. class:: NamedTuple
19681956

@@ -2399,7 +2387,8 @@ These are not used in annotations. They are building blocks for declaring types.
23992387
Protocols
24002388
---------
24012389

2402-
These protocols are decorated with :func:`runtime_checkable`.
2390+
The following protocols are provided by the typing module. All are decorated
2391+
with :func:`@runtime_checkable <runtime_checkable>`.
24032392

24042393
.. class:: SupportsAbs
24052394

@@ -3069,6 +3058,21 @@ Constant
30693058
Deprecated aliases
30703059
------------------
30713060

3061+
This module defines several deprecated aliases to pre-existing
3062+
standard library classes. These were originally included in the typing
3063+
module in order to support parameterizing these generic classes using ``[]``.
3064+
However, the aliases became redundant in Python 3.9 when the
3065+
corresponding pre-existing classes were enhanced to support ``[]``.
3066+
3067+
The redundant types are deprecated as of Python 3.9 but no
3068+
deprecation warnings are issued by the interpreter.
3069+
It is expected that type checkers will flag the deprecated types
3070+
when the checked program targets Python 3.9 or newer.
3071+
3072+
The deprecated types will be removed from the :mod:`typing` module
3073+
no sooner than the first Python version released 5 years after the release of Python 3.9.0.
3074+
See details in :pep:`585`—*Type Hinting Generics In Standard Collections*.
3075+
30723076
.. _corresponding-to-built-in-types:
30733077

30743078
Aliases to built-in types

0 commit comments

Comments
 (0)
0