Skip to content

Commit 2f4f538

Browse files
Merge branch 'main' into isolate-decimal-part1
2 parents 9e595e0 + 3fb7c60 commit 2f4f538

File tree

192 files changed

+7117
-2714
lines changed

Some content is hidden

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

192 files changed

+7117
-2714
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Parser/token.c generated
8686
Programs/test_frozenmain.h generated
8787
Python/Python-ast.c generated
8888
Python/generated_cases.c.h generated
89+
Python/executor_cases.c.h generated
8990
Python/opcode_targets.h generated
9091
Python/stdlib_module_names.h generated
9192
Tools/peg_generator/pegen/grammar_parser.py generated

.github/workflows/build.yml

+2-14
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'

.github/workflows/reusable-docs.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ jobs:
3838
uses: Ana06/[email protected]
3939
with:
4040
filter: "Doc/**"
41+
format: csv # works for paths with spaces
4142
- name: 'Build changed files in nit-picky mode'
4243
if: github.event_name == 'pull_request'
4344
continue-on-error: true
4445
run: |
46+
set -Eeuo pipefail
4547
# Mark files the pull request modified
46-
touch ${{ steps.changed_files.outputs.added_modified }}
48+
python Doc/tools/touch-clean-files.py --clean '${{ steps.changed_files.outputs.added_modified }}'
4749
# Build docs with the '-n' (nit-picky) option; convert warnings to annotations
4850
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n --keep-going" html 2>&1 |
4951
python Doc/tools/warnings-to-gh-actions.py

.pre-commit-config.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ 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]
811

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

Doc/c-api/none.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ same reason.
1515

1616
.. c:var:: PyObject* Py_None
1717
18-
The Python ``None`` object, denoting lack of value. This object has no methods.
19-
It needs to be treated just like any other object with respect to reference
20-
counts.
18+
The Python ``None`` object, denoting lack of value. This object has no methods
19+
and is `immortal <https://peps.python.org/pep-0683/>`_.
2120

21+
.. versionchanged:: 3.12
22+
:c:data:`Py_None` is immortal.
2223

2324
.. c:macro:: Py_RETURN_NONE
2425
25-
Properly handle returning :c:data:`Py_None` from within a C function (that is,
26-
increment the reference count of ``None`` and return it.)
26+
Return :c:data:`Py_None` from a function.

Doc/c-api/object.rst

+11-7
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ Object Protocol
3333
is equivalent to the Python expression ``hasattr(o, attr_name)``. This function
3434
always succeeds.
3535
36-
Note that exceptions which occur while calling :meth:`__getattr__` and
37-
:meth:`__getattribute__` methods will get suppressed.
38-
To get error reporting use :c:func:`PyObject_GetAttr()` instead.
36+
.. note::
37+
38+
Exceptions that occur when this calls :meth:`~object.__getattr__` and
39+
:meth:`~object.__getattribute__` methods are silently ignored.
40+
For proper error handling, use :c:func:`PyObject_GetAttr` instead.
3941
4042
4143
.. c:function:: int PyObject_HasAttrString(PyObject *o, const char *attr_name)
@@ -44,10 +46,12 @@ Object Protocol
4446
is equivalent to the Python expression ``hasattr(o, attr_name)``. This function
4547
always succeeds.
4648
47-
Note that exceptions which occur while calling :meth:`__getattr__` and
48-
:meth:`__getattribute__` methods and creating a temporary string object
49-
will get suppressed.
50-
To get error reporting use :c:func:`PyObject_GetAttrString()` instead.
49+
.. note::
50+
51+
Exceptions that occur when this calls :meth:`~object.__getattr__` and
52+
:meth:`~object.__getattribute__` methods or while creating the temporary :class:`str`
53+
object are silently ignored.
54+
For proper error handling, use :c:func:`PyObject_GetAttrString` instead.
5155
5256
5357
.. c:function:: PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name)

Doc/c-api/slice.rst

+6-3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ Ellipsis Object
118118
119119
.. c:var:: PyObject *Py_Ellipsis
120120
121-
The Python ``Ellipsis`` object. This object has no methods. It needs to be
122-
treated just like any other object with respect to reference counts. Like
123-
:c:data:`Py_None` it is a singleton object.
121+
The Python ``Ellipsis`` object. This object has no methods. Like
122+
:c:data:`Py_None`, it is an `immortal <https://peps.python.org/pep-0683/>`_.
123+
singleton object.
124+
125+
.. versionchanged:: 3.12
126+
:c:data:`Py_Ellipsis` is immortal.

Doc/c-api/tuple.rst

+16-7
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ Tuple Objects
8989
Like :c:func:`PyTuple_SetItem`, but does no error checking, and should *only* be
9090
used to fill in brand new tuples.
9191
92+
Bounds checking is performed as an assertion if Python is built in
93+
:ref:`debug mode <debug-build>` or :option:`with assertions <--with-assertions>`.
94+
9295
.. note::
9396
9497
This function "steals" a reference to *o*, and, unlike
@@ -194,12 +197,17 @@ type.
194197
.. c:function:: PyObject* PyStructSequence_GetItem(PyObject *p, Py_ssize_t pos)
195198
196199
Return the object at position *pos* in the struct sequence pointed to by *p*.
197-
No bounds checking is performed.
200+
201+
Bounds checking is performed as an assertion if Python is built in
202+
:ref:`debug mode <debug-build>` or :option:`with assertions <--with-assertions>`.
198203
199204
200205
.. c:function:: PyObject* PyStructSequence_GET_ITEM(PyObject *p, Py_ssize_t pos)
201206
202-
Macro equivalent of :c:func:`PyStructSequence_GetItem`.
207+
Alias to :c:func:`PyStructSequence_GetItem`.
208+
209+
.. versionchanged:: 3.13
210+
Now implemented as an alias to :c:func:`PyStructSequence_GetItem`.
203211
204212
205213
.. c:function:: void PyStructSequence_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o)
@@ -208,16 +216,17 @@ type.
208216
:c:func:`PyTuple_SET_ITEM`, this should only be used to fill in brand new
209217
instances.
210218
219+
Bounds checking is performed as an assertion if Python is built in
220+
:ref:`debug mode <debug-build>` or :option:`with assertions <--with-assertions>`.
221+
211222
.. note::
212223
213224
This function "steals" a reference to *o*.
214225
215226
216227
.. c:function:: void PyStructSequence_SET_ITEM(PyObject *p, Py_ssize_t *pos, PyObject *o)
217228
218-
Similar to :c:func:`PyStructSequence_SetItem`, but implemented as a static
219-
inlined function.
229+
Alias to :c:func:`PyStructSequence_SetItem`.
220230
221-
.. note::
222-
223-
This function "steals" a reference to *o*.
231+
.. versionchanged:: 3.13
232+
Now implemented as an alias to :c:func:`PyStructSequence_SetItem`.

Doc/c-api/weakref.rst

+25-8
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ simple reference object, and the second acts as a proxy for the original object
1111
as much as it can.
1212

1313

14-
.. c:function:: int PyWeakref_Check(ob)
14+
.. c:function:: int PyWeakref_Check(PyObject *ob)
1515
16-
Return true if *ob* is either a reference or proxy object. This function
16+
Return non-zero if *ob* is either a reference or proxy object. This function
1717
always succeeds.
1818
1919
20-
.. c:function:: int PyWeakref_CheckRef(ob)
20+
.. c:function:: int PyWeakref_CheckRef(PyObject *ob)
2121
22-
Return true if *ob* is a reference object. This function always succeeds.
22+
Return non-zero if *ob* is a reference object. This function always succeeds.
2323
2424
25-
.. c:function:: int PyWeakref_CheckProxy(ob)
25+
.. c:function:: int PyWeakref_CheckProxy(PyObject *ob)
2626
27-
Return true if *ob* is a proxy object. This function always succeeds.
27+
Return non-zero if *ob* is a proxy object. This function always succeeds.
2828
2929
3030
.. c:function:: PyObject* PyWeakref_NewRef(PyObject *ob, PyObject *callback)
@@ -51,10 +51,21 @@ as much as it can.
5151
``None``, or ``NULL``, this will return ``NULL`` and raise :exc:`TypeError`.
5252
5353
54+
.. c:function:: int PyWeakref_GetRef(PyObject *ref, PyObject **pobj)
55+
56+
Get a :term:`strong reference` to the referenced object from a weak
57+
reference, *ref*, into *\*pobj*.
58+
Return 0 on success. Raise an exception and return -1 on error.
59+
60+
If the referent is no longer live, set *\*pobj* to ``NULL`` and return 0.
61+
62+
.. versionadded:: 3.13
63+
64+
5465
.. c:function:: PyObject* PyWeakref_GetObject(PyObject *ref)
5566
56-
Return the referenced object from a weak reference, *ref*. If the referent is
57-
no longer live, returns :const:`Py_None`.
67+
Return a :term:`borrowed reference` to the referenced object from a weak
68+
reference, *ref*. If the referent is no longer live, returns ``Py_None``.
5869
5970
.. note::
6071
@@ -63,11 +74,17 @@ as much as it can.
6374
except when it cannot be destroyed before the last usage of the borrowed
6475
reference.
6576
77+
.. deprecated-removed:: 3.13 3.15
78+
Use :c:func:`PyWeakref_GetRef` instead.
79+
6680
6781
.. c:function:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
6882
6983
Similar to :c:func:`PyWeakref_GetObject`, but does no error checking.
7084
85+
.. deprecated-removed:: 3.13 3.15
86+
Use :c:func:`PyWeakref_GetRef` instead.
87+
7188
7289
.. c:function:: void PyObject_ClearWeakRefs(PyObject *object)
7390

0 commit comments

Comments
 (0)