8000 Merge branch 'main' into bytes_join · python/cpython@9594096 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9594096

Browse files
committed
Merge branch 'main' into bytes_join
2 parents 6353240 + 7fca268 commit 9594096

File tree

166 files changed

+1678
-913
lines changed

Some content is hidden

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

166 files changed

+1678
-913
lines changed

Doc/c-api/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ propagated, additional calls into the Python/C API may not behave as intended
3434
and may fail in mysterious ways.
3535

3636
.. note::
37-
The error indicator is **not** the result of :func:`sys.exc_info()`.
37+
The error indicator is **not** the result of :func:`sys.exc_info`.
3838
The former corresponds to an exception that is not yet caught (and is
3939
therefore still propagating), while the latter returns an exception after
4040
it is caught (and has therefore stopped propagating).

Doc/c-api/import.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Importing Modules
190190
191191
.. versionadded:: 3.2
192192
.. versionchanged:: 3.3
193-
Uses :func:`!imp.source_from_cache()` in calculating the source path if
193+
Uses :func:`!imp.source_from_cache` in calculating the source path if
194194
only the bytecode path is provided.
195195
.. versionchanged:: 3.12
196196
No longer uses the removed :mod:`!imp` module.

Doc/c-api/init.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ Initializing and finalizing the interpreter
426426
loaded extension modules loaded by Python are not unloaded. Small amounts of
427427
memory allocated by the Python interpreter may not be freed (if you find a leak,
428428
please report it). Memory tied up in circular references between objects is not
429-
freed. Interned strings will all be deallocated regarldess of their reference count.
429+
freed. Interned strings will all be deallocated regardless of their reference count.
430430
Some memory allocated by extension modules may not be freed. Some extensions may not
431431
work properly if their initialization routine is called more than once; this can
432432
happen if an application calls :c:func:`Py_Initialize` and :c:func:`Py_FinalizeEx`

Doc/c-api/long.rst

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,32 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
6969
on failure.
7070
7171
72+
.. c:function:: PyObject* PyLong_FromInt32(int32_t value)
73+
PyObject* PyLong_FromInt64(int64_t value)
74+
75+
Return a new :c:type:`PyLongObject` object from a signed C
76+
:c:expr:`int32_t` or :c:expr:`int64_t`, or ``NULL``
77+
with an exception set on failure.
78+
79+
.. versionadded:: 3.14
80+
81+
7282
.. c:function:: PyObject* PyLong_FromUnsignedLongLong(unsigned long long v)
7383
7484
Return a new :c:type:`PyLongObject` object from a C :c:expr:`unsigned long long`,
7585
or ``NULL`` on failure.
7686
7787
88+
.. c:function:: PyObject* PyLong_FromUInt32(uint32_t value)
89+
PyObject* PyLong_FromUInt64(uint64_t value)
90+
91+
Return a new :c:type:`PyLongObject` object from an unsigned C
92+
:c:expr:`uint32_t` or :c:expr:`uint64_t`, or ``NULL``
93+
with an exception set on failure.
94+
95+
.. versionadded:: 3.14
96+
97+
7898
.. c:function:: PyObject* PyLong_FromDouble(double v)
7999
80100
Return a new :c:type:`PyLongObject` object from the integer part of *v*, or
@@ -337,6 +357,43 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
337357
This function will no longer use :meth:`~object.__int__`.
338358
339359
360+
.. c:function:: int PyLong_AsInt32(PyObject *obj, int32_t *value)
361+
int PyLong_AsInt64(PyObject *obj, int64_t *value)
362+
363+
Set *\*value* to a signed C :c:expr:`int32_t` or :c:expr:`int64_t`
364+
representation of *obj*.
365+
366+
If the *obj* value is out of range, raise an :exc:`OverflowError`.
367+
368+
Set *\*value* and return ``0`` on success.
369+
Set an exception and return ``-1`` on error.
370+
371+
*value* must not be ``NULL``.
372+
373+
.. versionadded:: 3.14
374+
375+
376+
.. c:function:: int PyLong_AsUInt32(PyObject *obj, uint32_t *value)
377+
int PyLong_AsUInt64(PyObject *obj, uint64_t *value)
378+
379+
Set *\*value* to an unsigned C :c:expr:`uint32_t` or :c:expr:`uint64_t`
380+
representation of *obj*.
381+
382+
If *obj* is not an instance of :c:type:`PyLongObject`, first call its
383+
:meth:`~object.__index__` method (if present) to convert it to a
384+
:c:type:`PyLongObject`.
385+
386+
* If *obj* is negative, raise a :exc:`ValueError`.
387+
* If the *obj* value is out of range, raise an :exc:`OverflowError`.
388+
389+
Set *\*value* and return ``0`` on success.
390+
Set an exception and return ``-1`` on error.
391+
392+
*value* must not be ``NULL``.
393+
394+
.. versionadded:: 3.14
395+
396+
340397
.. c:function:: double PyLong_AsDouble(PyObject *pylong)
341398
342399
Return a C :c:expr:`double` representation of *pylong*. *pylong* must be

Doc/c-api/tuple.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,27 @@ Tuple Objects
3333
3434
.. c:function:: PyObject* PyTuple_New(Py_ssize_t len)
3535
36-
Return a new tuple object of size *len*, or ``NULL`` on failure.
36+
Return a new tuple object of size *len*,
37+
or ``NULL`` with an exception set on failure.
3738
3839
3940
.. c:function:: PyObject* PyTuple_Pack(Py_ssize_t n, ...)
4041
41-
Return a new tuple object of size *n*, or ``NULL`` on failure. The tuple values
42+
Return a new tuple object of size *n*,
43+
or ``NULL`` with an exception set on failure. The tuple values
4244
are initialized to the subsequent *n* C arguments pointing to Python objects.
4345
``PyTuple_Pack(2, a, b)`` is equivalent to ``Py_BuildValue("(OO)", a, b)``.
4446
4547
4648
.. c:function:: Py_ssize_t PyTuple_Size(PyObject *p)
4749
4850
Take a pointer to a tuple object, and return the size of that tuple.
51+
On error, return ``-1`` and with an exception set.
4952
5053
5154
.. c:function:: Py_ssize_t PyTuple_GET_SIZE(PyObject *p)
5255
53-
Return the size of the tuple *p*, which must be non-``NULL`` and point to a tuple;
54-
no error checking is performed.
56+
Like :c:func:`PyTuple_Size`, but without error checking.
5557
5658
5759
.. c:function:: PyObject* PyTuple_GetItem(PyObject *p, Py_ssize_t pos)
@@ -74,8 +76,10 @@ Tuple Objects
7476
.. c:function:: PyObject* PyTuple_GetSlice(PyObject *p, Py_ssize_t low, Py_ssize_t high)
7577
7678
Return the slice of the tuple pointed to by *p* between *low* and *high*,
77-
or ``NULL`` on failure. This is the equivalent of the Python expression
78-
``p[low:high]``. Indexing from the end of the tuple is not supported.
79+
or ``NULL`` with an exception set on failure.
80+
81+
This is the equivalent of the Python expression ``p[low:high]``.
82+
Indexing from the end of the tuple is not supported.
7983
8084
8185
.. c:function:: int PyTuple_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o)
@@ -141,6 +145,8 @@ type.
141145
Create a new struct sequence type from the data in *desc*, described below. Instances
142146
of the resulting type can be created with :c:func:`PyStructSequence_New`.
143147
148+
Return ``NULL`` with an exception set on failure.
149+
144150
145151
.. c:function:: void PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc)
146152
@@ -149,8 +155,8 @@ type.
149155
150156
.. c:function:: int PyStructSequence_InitType2(PyTypeObject *type, PyStructSequence_Desc *desc)
151157
152-
The same as ``PyStructSequence_InitType``, but returns ``0`` on success and ``-1`` on
153-
failure.
158+
Like :c:func:`PyStructSequence_InitType`, but returns ``0`` on success
159+
and ``-1`` with an exception set on failure.
154160
155161
.. versionadded:: 3.4
156162
@@ -207,6 +213,8 @@ type.
207213
Creates an instance of *type*, which must have been created with
208214
:c:func:`PyStructSequence_NewType`.
209215
216+
Return ``NULL`` with an exception set on failure.
217+
210218
211219
.. c:function:: PyObject* PyStructSequence_GetItem(PyObject *p, Py_ssize_t pos)
212220

Doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
('c:type', 'size_t'),
142142
('c:type', 'ssize_t'),
143143
('c:type', 'time_t'),
144+
('c:type', 'uint32_t'),
144145
('c:type', 'uint64_t'),
145146
('c:type', 'uintmax_t'),
146147
('c:type', 'uintptr_t'),

Doc/data/stable_abi.dat

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

Doc/deprecations/pending-removal-in-3.13.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ APIs:
4848
* ``read_binary()``
4949
* ``read_text()``
5050

51-
Use :func:`importlib.resources.files()` instead. Refer to `importlib-resources: Migrating from Legacy
51+
Use :func:`importlib.resources.files` instead. Refer to `importlib-resources: Migrating from Legacy
5252
<https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy>`_ (:gh:`106531`)

Doc/deprecations/pending-removal-in-3.15.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Pending Removal in Python 3.15
99
* :class:`locale`: :func:`locale.getdefaultlocale` was deprecated in Python 3.11
1010
and originally planned for removal in Python 3.13 (:gh:`90817`),
1111
but removal has been postponed to Python 3.15.
12-
Use :func:`locale.setlocale()`, :func:`locale.getencoding()` and
13-
:func:`locale.getlocale()` instead.
12+
Use :func:`locale.setlocale`, :func:`locale.getencoding` and
13+
:func:`locale.getlocale` instead.
1414
(Contributed by Hugo van Kemenade in :gh:`111187`.)
1515

1616
* :mod:`pathlib`:

Doc/glossary.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -590,14 +590,12 @@ Glossary
590590
which ships with the standard distribution of Python.
591591

592592
immortal
593-
If an object is immortal, its reference count is never modified, and
594-
therefore it is never deallocated.
593+
*Immortal objects* are a CPython implementation detail introduced
594+
in :pep:`683`.
595595

596-
Built-in strings and singletons are immortal objects. For example,
597-
:const:`True` and :const:`None` singletons are immortal.
598-
599-
See `PEP 683 – Immortal Objects, Using a Fixed Refcount
600-
<https://peps.python.org/pep-0683/>`_ for more information.
596+
If an object is immortal, its :term:`reference count` is never modified,
597+
and therefore it is never deallocated while the interpreter is running.
598+
For example, :const:`True` and :const:`None` are immortal in CPython.
601599

602600
immutable
603601
An object with a fixed value. Immutable objects include numbers, strings and

0 commit comments

Comments
 (0)
0