Skip to content

Commit ac11740

Browse files
committed
Merge branch 'main' into modulelocals
* main: (167 commits) pythongh-91053: make func watcher tests resilient to other func watchers (python#106286) pythongh-104050: Add more type hints to Argument Clinic DSLParser() (python#106354) pythongh-106359: Fix corner case bugs in Argument Clinic converter parser (python#106361) pythongh-104146: Remove unused attr 'parameter_indent' from clinic.DLParser (python#106358) pythongh-106320: Remove private _PyErr C API functions (python#106356) pythongh-104050: Annotate Argument Clinic DSLParser attributes (python#106357) pythongh-106320: Create pycore_modsupport.h header file (python#106355) pythongh-106320: Move _PyUnicodeWriter to the internal C API (python#106342) pythongh-61215: New mock to wait for multi-threaded events to happen (python#16094) Document PYTHONSAFEPATH along side -P (python#106122) Replace the esoteric term 'datum' when describing dict comprehensions (python#106119) pythongh-104050: Add more type hints to Argument Clinic DSLParser() (python#106343) pythongh-106320: _testcapi avoids private _PyUnicode_EqualToASCIIString() (python#106341) pythongh-106320: Add pycore_complexobject.h header file (python#106339) pythongh-106078: Move DecimalException to _decimal state (python#106301) pythongh-106320: Use _PyInterpreterState_GET() (python#106336) pythongh-106320: Remove private _PyInterpreterState functions (python#106335) pythongh-104922: Doc: add note about PY_SSIZE_T_CLEAN (python#106314) pythongh-106217: Truncate the issue body size of `new-bugs-announce-notifier` (python#106329) pythongh-104922: remove PY_SSIZE_T_CLEAN (python#106315) ...
2 parents 1e27721 + 5890621 commit ac11740

File tree

399 files changed

+12300
-6442
lines changed

Some content is hidden

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

399 files changed

+12300
-6442
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ 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
90+
Python/opcode_metadata.h generated
8991
Python/opcode_targets.h generated
9092
Python/stdlib_module_names.h generated
9193
Tools/peg_generator/pegen/grammar_parser.py generated

.github/CODEOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Doc/library/time.rst @pganssle @abalkin
7979
Lib/test/test_time.py @pganssle @abalkin
8080
Modules/timemodule.c @pganssle @abalkin
8181
Python/pytime.c @pganssle @abalkin
82-
Include/pytime.h @pganssle @abalkin
82+
Include/internal/pycore_time.h @pganssle @abalkin
8383

8484
# Email and related
8585
**/*mail* @python/email-team

.github/workflows/build.yml

+4-16
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,9 @@ jobs:
8787
with:
8888
filter: |
8989
Doc/**
90-
# Temporarily skip paths with spaces
91-
# (i.e. "C API", "Core and Builtins")
92-
# to avoid "Error: One of your files includes a space".
93-
# Pending https://github.com/python/core-workflow/issues/186
94-
# Misc/**
95-
Misc/NEWS.d/next/Build/**
96-
Misc/NEWS.d/next/Documentation/**
97-
Misc/NEWS.d/next/IDLE/**
98-
Misc/NEWS.d/next/Library/**
99-
Misc/NEWS.d/next/Security/**
100-
Misc/NEWS.d/next/Tests/**
101-
Misc/NEWS.d/next/Tools-Demos/**
102-
Misc/NEWS.d/next/Windows/**
103-
Misc/NEWS.d/next/macOS/**
90+
Misc/**
10491
.github/workflows/reusable-docs.yml
92+
format: csv # works for paths with spaces
10593
- name: Check for docs changes
10694
if: >-
10795
github.event_name == 'pull_request'
@@ -232,7 +220,7 @@ jobs:
232220
path: config.cache
233221
key: ${{ github.job }}-${{ runner.os }}-${{ needs.check_source.outputs.config_hash }}
234222
- name: Install Homebrew dependencies
235-
run: brew install pkg-config openssl@1.1 xz gdbm tcl-tk
223+
run: brew install pkg-config openssl@3.0 xz gdbm tcl-tk
236224
- name: Configure CPython
237225
run: |
238226
GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \
@@ -241,7 +229,7 @@ jobs:
241229
--config-cache \
242230
--with-pydebug \
243231
--prefix=/opt/python-dev \
244-
--with-openssl="$(brew --prefix openssl@1.1)"
232+
--with-openssl="$(brew --prefix openssl@3.0)"
245233
- name: Build CPython
246234
run: make -j4
247235
- name: Display build info

.github/workflows/new-bugs-announce-notifier.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ jobs:
4141
url : issue.data.html_url,
4242
labels : issue.data.labels.map(label => { return label.name }).join(", "),
4343
assignee : issue.data.assignees.map(assignee => { return assignee.login }),
44-
body : issue.data.body
44+
// We need to truncate the body size, because the max size for
45+
// the whole payload is 16kb. We want to be safe and assume that
46+
// body can take up to ~8kb of space.
47+
body : issue.data.body.substring(8000)
4548
};
4649
4750
const data = {

.github/workflows/require-pr-label.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
timeout-minutes: 10
1616

1717
steps:
18-
- uses: mheap/github-action-required-labels@v4
18+
- uses: mheap/github-action-required-labels@v5
1919
with:
2020
mode: exactly
2121
count: 0

.github/workflows/reusable-docs.yml

+3-5
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

@@ -40,12 +38,14 @@ jobs:
4038
uses: Ana06/[email protected]
4139
with:
4240
filter: "Doc/**"
41+
format: csv # works for paths with spaces
4342
- name: 'Build changed files in nit-picky mode'
4443
if: github.event_name == 'pull_request'
4544
continue-on-error: true
4645
run: |
46+
set -Eeuo pipefail
4747
# Mark files the pull request modified
48-
touch ${{ steps.changed_files.outputs.added_modified }}
48+
python Doc/tools/touch-clean-files.py --clean '${{ steps.changed_files.outputs.added_modified }}'
4949
# Build docs with the '-n' (nit-picky) option; convert warnings to annotations
5050
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n --keep-going" html 2>&1 |
5151
python Doc/tools/warnings-to-gh-actions.py
@@ -59,8 +59,6 @@ jobs:
5959
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n -W --keep-going" html 2>&1
6060
6161
# 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.
6462
build_doc_oldest_supported_sphinx:
6563
name: 'Docs (Oldest Sphinx)'
6664
runs-on: ubuntu-latest

.pre-commit-config.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,16 @@ 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]
11+
12+
- repo: https://github.com/sphinx-contrib/sphinx-lint
13+
rev: v0.6.7
14+
hooks:
15+
- id: sphinx-lint
16+
args: [--enable=default-role]
17+
files: ^Doc/
18+
types: [rst]

Doc/Makefile

+3-5
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/bool.rst

+14-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Boolean Objects
66
---------------
77

88
Booleans in Python are implemented as a subclass of integers. There are only
9-
two booleans, :const:`Py_False` and :const:`Py_True`. As such, the normal
9+
two booleans, :c:data:`Py_False` and :c:data:`Py_True`. As such, the normal
1010
creation and deletion functions don't apply to booleans. The following macros
1111
are available, however.
1212

@@ -19,29 +19,32 @@ are available, however.
1919
2020
.. c:var:: PyObject* Py_False
2121
22-
The Python ``False`` object. This object has no methods. It needs to be
23-
treated just like any other object with respect to reference counts.
22+
The Python ``False`` object. This object has no methods and is
23+
`immortal <https://peps.python.org/pep-0683/>`_.
24+
25+
.. versionchanged:: 3.12
26+
:c:data:`Py_False` is immortal.
2427
2528
2629
.. c:var:: PyObject* Py_True
2730
28-
The Python ``True`` object. This object has no methods. It needs to be treated
29-
just like any other object with respect to reference counts.
31+
The Python ``True`` object. This object has no methods and is
32+
`immortal <https://peps.python.org/pep-0683/>`_.
33+
34+
.. versionchanged:: 3.12
35+
:c:data:`Py_True` is immortal.
3036
3137
3238
.. c:macro:: Py_RETURN_FALSE
3339
34-
Return :const:`Py_False` from a function, properly incrementing its reference
35-
count.
40+
Return :c:data:`Py_False` from a function.
3641
3742
3843
.. c:macro:: Py_RETURN_TRUE
3944
40-
Return :const:`Py_True` from a function, properly incrementing its reference
41-
count.
45+
Return :c:data:`Py_True` from a function.
4246
4347
4448
.. c:function:: PyObject* PyBool_FromLong(long v)
4549
46-
Return a new reference to :const:`Py_True` or :const:`Py_False` depending on the
47-
truth value of *v*.
50+
Return :c:data:`Py_True` or :c:data:`Py_False`, depending on the truth value of *v*.

Doc/c-api/call.rst

-13
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,6 @@ function as with any other callable.
113113
:c:func:`PyObject_Vectorcall` will usually be most efficient.
114114

115115

116-
.. note::
117-
118-
In CPython 3.8, the vectorcall API and related functions were available
119-
provisionally under names with a leading underscore:
120-
``_PyObject_Vectorcall``, ``_Py_TPFLAGS_HAVE_VECTORCALL``,
121-
``_PyObject_VectorcallMethod``, ``_PyVectorcall_Function``,
122-
``_PyObject_CallOneArg``, ``_PyObject_CallMethodNoArgs``,
123-
``_PyObject_CallMethodOneArg``.
124-
Additionally, ``PyObject_VectorcallDict`` was available as
125-
``_PyObject_FastCallDict``.
126-
The old names are still defined as aliases of the new, non-underscored names.
127-
128-
129116
Recursion Control
130117
.................
131118

Doc/c-api/complex.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ Complex Numbers as Python Objects
127127
128128
Return the :c:type:`Py_complex` value of the complex number *op*.
129129
130-
If *op* is not a Python complex number object but has a :meth:`__complex__`
130+
If *op* is not a Python complex number object but has a :meth:`~object.__complex__`
131131
method, this method will first be called to convert *op* to a Python complex
132-
number object. If ``__complex__()`` is not defined then it falls back to
133-
:meth:`__float__`. If ``__float__()`` is not defined then it falls back
134-
to :meth:`__index__`. Upon failure, this method returns ``-1.0`` as a real
132+
number object. If :meth:`!__complex__` is not defined then it falls back to
133+
:meth:`~object.__float__`. If :meth:`!__float__` is not defined then it falls back
134+
to :meth:`~object.__index__`. Upon failure, this method returns ``-1.0`` as a real
135135
value.
136136
137137
.. versionchanged:: 3.8
138-
Use :meth:`__index__` if available.
138+
Use :meth:`~object.__index__` if available.

Doc/c-api/dict.rst

+12-7
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/float.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ Floating Point Objects
4545
.. c:function:: double PyFloat_AsDouble(PyObject *pyfloat)
4646
4747
Return a C :c:expr:`double` representation of the contents of *pyfloat*. If
48-
*pyfloat* is not a Python floating point object but has a :meth:`__float__`
48+
*pyfloat* is not a Python floating point object but has a :meth:`~object.__float__`
4949
method, this method will first be called to convert *pyfloat* into a float.
50-
If ``__float__()`` is not defined then it falls back to :meth:`__index__`.
50+
If :meth:`!__float__` is not defined then it falls back to :meth:`~object.__index__`.
5151
This method returns ``-1.0`` upon failure, so one should call
5252
:c:func:`PyErr_Occurred` to check for errors.
5353
5454
.. versionchanged:: 3.8
55-
Use :meth:`__index__` if available.
55+
Use :meth:`~object.__index__` if available.
5656
5757
5858
.. c:function:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)

Doc/c-api/import.rst

+25-12
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/c-api/list.rst

+4
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

0 commit comments

Comments
 (0)