Skip to content

Commit de55c4f

Browse files
authored
Merge branch 'main' into fix-warnings-simplefilter-filterwarnings
2 parents 022e4b3 + f1b8d01 commit de55c4f

File tree

151 files changed

+2529
-1583
lines changed

Some content is hidden

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

151 files changed

+2529
-1583
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Modules/Setup* @erlend-aasland
2626
**/*context* @1st1
2727
**/*genobject* @markshannon
2828
**/*hamt* @1st1
29-
**/*jit* @brandtbucher @savannahostrowski
29+
**/*jit* @brandtbucher @savannahostrowski @diegorusso
3030
Objects/set* @rhettinger
3131
Objects/dict* @methane @markshannon
3232
Objects/typevarobject.c @JelleZijlstra

Android/android.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def unpack_deps(host, prefix_dir):
175175
os.chdir(prefix_dir)
176176
deps_url = "https://github.com/beeware/cpython-android-source-deps/releases/download"
177177
for name_ver in ["bzip2-1.0.8-3", "libffi-3.4.4-3", "openssl-3.0.15-4",
178-
"sqlite-3.49.1-0", "xz-5.4.6-1"]:
178+
"sqlite-3.49.1-0", "xz-5.4.6-1", "zstd-1.5.7-1"]:
179179
filename = f"{name_ver}-{host}.tar.gz"
180180
download(f"{deps_url}/{name_ver}/{filename}")
181181
shutil.unpack_archive(filename)

Doc/c-api/code.rst

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,71 @@ bound into a function.
211211
.. versionadded:: 3.12
212212
213213
214+
.. _c_codeobject_flags:
215+
216+
Code Object Flags
217+
-----------------
218+
219+
Code objects contain a bit-field of flags, which can be retrieved as the
220+
:attr:`~codeobject.co_flags` Python attribute (for example using
221+
:c:func:`PyObject_GetAttrString`), and set using a *flags* argument to
222+
:c:func:`PyUnstable_Code_New` and similar functions.
223+
224+
Flags whose names start with ``CO_FUTURE_`` correspond to features normally
225+
selectable by :ref:`future statements <future>`. These flags can be used in
226+
:c:member:`PyCompilerFlags.cf_flags`.
227+
Note that many ``CO_FUTURE_`` flags are mandatory in current versions of
228+
Python, and setting them has no effect.
229+
230+
The following flags are available.
231+
For their meaning, see the linked documentation of their Python equivalents.
232+
233+
234+
.. list-table::
235+
:widths: auto
236+
:header-rows: 1
237+
238+
* * Flag
239+
* Meaning
240+
* * .. c:macro:: CO_OPTIMIZED
241+
* :py:data:`inspect.CO_OPTIMIZED`
242+
* * .. c:macro:: CO_NEWLOCALS
243+
* :py:data:`inspect.CO_NEWLOCALS`
244+
* * .. c:macro:: CO_VARARGS
245+
* :py:data:`inspect.CO_VARARGS`
246+
* * .. c:macro:: CO_VARKEYWORDS
247+
* :py:data:`inspect.CO_VARKEYWORDS`
248+
* * .. c:macro:: CO_NESTED
249+
* :py:data:`inspect.CO_NESTED`
250+
* * .. c:macro:: CO_GENERATOR
251+
* :py:data:`inspect.CO_GENERATOR`
252+
* * .. c:macro:: CO_COROUTINE
253+
* :py:data:`inspect.CO_COROUTINE`
254+
* * .. c:macro:: CO_ITERABLE_COROUTINE
255+
* :py:data:`inspect.CO_ITERABLE_COROUTINE`
256+
* * .. c:macro:: CO_ASYNC_GENERATOR
257+
* :py:data:`inspect.CO_ASYNC_GENERATOR`
258+
* * .. c:macro:: CO_HAS_DOCSTRING
259+
* :py:data:`inspect.CO_HAS_DOCSTRING`
260+
* * .. c:macro:: CO_METHOD
261+
* :py:data:`inspect.CO_METHOD`
262+
263+
* * .. c:macro:: CO_FUTURE_DIVISION
264+
* no effect (:py:data:`__future__.division`)
265+
* * .. c:macro:: CO_FUTURE_ABSOLUTE_IMPORT
266+
* no effect (:py:data:`__future__.absolute_import`)
267+
* * .. c:macro:: CO_FUTURE_WITH_STATEMENT
268+
* no effect (:py:data:`__future__.with_statement`)
269+
* * .. c:macro:: CO_FUTURE_PRINT_FUNCTION
270+
* no effect (:py:data:`__future__.print_function`)
271+
* * .. c:macro:: CO_FUTURE_UNICODE_LITERALS
272+
* no effect (:py:data:`__future__.unicode_literals`)
273+
* * .. c:macro:: CO_FUTURE_GENERATOR_STOP
274+
* no effect (:py:data:`__future__.generator_stop`)
275+
* * .. c:macro:: CO_FUTURE_ANNOTATIONS
276+
* :py:data:`__future__.annotations`
277+
278+
214279
Extra information
215280
-----------------
216281

Doc/c-api/exceptions.rst

Lines changed: 187 additions & 251 deletions
Large diffs are not rendered by default.

Doc/c-api/structures.rst

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,52 @@ under :ref:`reference counting <countingrefs>`.
2828
object. In a normal "release" build, it contains only the object's
2929
reference count and a pointer to the corresponding type object.
3030
Nothing is actually declared to be a :c:type:`PyObject`, but every pointer
31-
to a Python object can be cast to a :c:expr:`PyObject*`. Access to the
32-
members must be done by using the macros :c:macro:`Py_REFCNT` and
33-
:c:macro:`Py_TYPE`.
31+
to a Python object can be cast to a :c:expr:`PyObject*`.
32+
33+
The members must not be accessed directly; instead use macros such as
34+
:c:macro:`Py_REFCNT` and :c:macro:`Py_TYPE`.
35+
36+
.. c:member:: Py_ssize_t ob_refcnt
37+
38+
The object's reference count, as returned by :c:macro:`Py_REFCNT`.
39+
Do not use this field directly; instead use functions and macros such as
40+
:c:macro:`!Py_REFCNT`, :c:func:`Py_INCREF` and :c:func:`Py_DecRef`.
41+
42+
The field type may be different from ``Py_ssize_t``, depending on
43+
build configuration and platform.
44+
45+
.. c:member:: PyTypeObject* ob_type
46+
47+
The object's type.
48+
Do not use this field directly; use :c:macro:`Py_TYPE` and
49+
:c:func:`Py_SET_TYPE` instead.
3450

3551

3652
.. c:type:: PyVarObject
3753
38-
This is an extension of :c:type:`PyObject` that adds the :c:member:`~PyVarObject.ob_size`
39-
field. This is only used for objects that have some notion of *length*.
40-
This type does not often appear in the Python/C API.
41-
Access to the members must be done by using the macros
42-
:c:macro:`Py_REFCNT`, :c:macro:`Py_TYPE`, and :c:macro:`Py_SIZE`.
54+
An extension of :c:type:`PyObject` that adds the
55+
:c:member:`~PyVarObject.ob_size` field.
56+
This is intended for objects that have some notion of *length*.
57+
58+
As with :c:type:`!PyObject`, the members must not be accessed directly;
59+
instead use macros such as :c:macro:`Py_SIZE`, :c:macro:`Py_REFCNT` and
60+
:c:macro:`Py_TYPE`.
61+
62+
.. c:member:: Py_ssize_t ob_size
63+
64+
A size field, whose contents should be considered an object's internal
65+
implementation detail.
66+
67+
Do not use this field directly; use :c:macro:`Py_SIZE` instead.
68+
69+
Object creation functions such as :c:func:`PyObject_NewVar` will
70+
generally set this field to the requested size (number of items).
71+
After creation, arbitrary values can be stored in :c:member:`!ob_size`
72+
using :c:macro:`Py_SET_SIZE`.
73+
74+
To get an object's publicly exposed length, as returned by
75+
the Python function :py:func:`len`, use :c:func:`PyObject_Length`
76+
instead.
4377

4478

4579
.. c:macro:: PyObject_HEAD
@@ -103,9 +137,8 @@ under :ref:`reference counting <countingrefs>`.
103137
104138
Get the type of the Python object *o*.
105139
106-
Return a :term:`borrowed reference`.
107-
108-
Use the :c:func:`Py_SET_TYPE` function to set an object type.
140+
The returned reference is :term:`borrowed <borrowed reference>` from *o*.
141+
Do not release it with :c:func:`Py_DECREF` or similar.
109142
110143
.. versionchanged:: 3.11
111144
:c:func:`Py_TYPE()` is changed to an inline static function.
@@ -122,16 +155,26 @@ under :ref:`reference counting <countingrefs>`.
122155
123156
.. c:function:: void Py_SET_TYPE(PyObject *o, PyTypeObject *type)
124157
125-
Set the object *o* type to *type*.
158+
Set the type of object *o* to *type*, without any checking or reference
159+
counting.
160+
161+
This is a very low-level operation.
162+
Consider instead setting the Python attribute :attr:`~object.__class__`
163+
using :c:func:`PyObject_SetAttrString` or similar.
164+
165+
Note that assigning an incompatible type can lead to undefined behavior.
166+
167+
If *type* is a :ref:`heap type <heap-types>`, the caller must create a
168+
new reference to it.
169+
Similarly, if the old type of *o* is a heap type, the caller must release
170+
a reference to that type.
126171
127172
.. versionadded:: 3.9
128173
129174
130175
.. c:function:: Py_ssize_t Py_SIZE(PyVarObject *o)
131176
132-
Get the size of the Python object *o*.
133-
134-
Use the :c:func:`Py_SET_SIZE` function to set an object size.
177+
Get the :c:member:`~PyVarObject.ob_size` field of *o*.
135178
136179
.. versionchanged:: 3.11
137180
:c:func:`Py_SIZE()` is changed to an inline static function.
@@ -140,7 +183,7 @@ under :ref:`reference counting <countingrefs>`.
140183
141184
.. c:function:: void Py_SET_SIZE(PyVarObject *o, Py_ssize_t size)
142185
143-
Set the object *o* size to *size*.
186+
Set the :c:member:`~PyVarObject.ob_size` field of *o* to *size*.
144187
145188
.. versionadded:: 3.9
146189

Doc/c-api/typeobj.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,9 @@ metatype) initializes :c:member:`~PyTypeObject.tp_itemsize`, which means that it
492492
type objects) *must* have the :c:member:`~PyVarObject.ob_size` field.
493493

494494

495-
.. c:member:: Py_ssize_t PyObject.ob_refcnt
495+
:c:member:`PyObject.ob_refcnt`
496496

497-
This is the type object's reference count, initialized to ``1`` by the
497+
The type object's reference count is initialized to ``1`` by the
498498
``PyObject_HEAD_INIT`` macro. Note that for :ref:`statically allocated type
499499
objects <static-types>`, the type's instances (objects whose :c:member:`~PyObject.ob_type`
500500
points back to the type) do *not* count as references. But for
@@ -506,7 +506,7 @@ type objects) *must* have the :c:member:`~PyVarObject.ob_size` field.
506506
This field is not inherited by subtypes.
507507

508508

509-
.. c:member:: PyTypeObject* PyObject.ob_type
509+
:c:member:`PyObject.ob_type`
510510

511511
This is the type's type, in other words its metatype. It is initialized by the
512512
argument to the ``PyObject_HEAD_INIT`` macro, and its value should normally be
@@ -532,14 +532,13 @@ type objects) *must* have the :c:member:`~PyVarObject.ob_size` field.
532532
PyVarObject Slots
533533
-----------------
534534

535-
.. c:member:: Py_ssize_t PyVarObject.ob_size
535+
:c:member:`PyVarObject.ob_size`
536536

537537
For :ref:`statically allocated type objects <static-types>`, this should be
538538
initialized to zero. For :ref:`dynamically allocated type objects
539539
<heap-types>`, this field has a special internal meaning.
540540

541-
This field should be accessed using the :c:func:`Py_SIZE()` and
542-
:c:func:`Py_SET_SIZE()` macros.
541+
This field should be accessed using the :c:func:`Py_SIZE()` macro.
543542

544543
**Inheritance:**
545544

Doc/c-api/veryhigh.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ the same library that the Python runtime is using.
361361
:py:mod:`!ast` Python module, which exports these constants under
362362
the same names.
363363
364-
.. c:var:: int CO_FUTURE_DIVISION
365-
366-
This bit can be set in *flags* to cause division operator ``/`` to be
367-
interpreted as "true division" according to :pep:`238`.
364+
The "``PyCF``" flags above can be combined with "``CO_FUTURE``" flags such
365+
as :c:macro:`CO_FUTURE_ANNOTATIONS` to enable features normally
366+
selectable using :ref:`future statements <future>`.
367+
See :ref:`c_codeobject_flags` for a complete list.

Doc/conf.py

Lines changed: 10 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -233,75 +233,6 @@
233233
# Temporary undocumented names.
234234
# In future this list must be empty.
235235
nitpick_ignore += [
236-
# C API: Standard Python exception classes
237-
('c:data', 'PyExc_ArithmeticError'),
238-
('c:data', 'PyExc_AssertionError'),
239-
('c:data', 'PyExc_AttributeError'),
240-
('c:data', 'PyExc_BaseException'),
241-
('c:data', 'PyExc_BaseExceptionGroup'),
242-
('c:data', 'PyExc_BlockingIOError'),
243-
('c:data', 'PyExc_BrokenPipeError'),
244-
('c:data', 'PyExc_BufferError'),
245-
('c:data', 'PyExc_ChildProcessError'),
246-
('c:data', 'PyExc_ConnectionAbortedError'),
247-
('c:data', 'PyExc_ConnectionError'),
248-
('c:data', 'PyExc_ConnectionRefusedError'),
249-
('c:data', 'PyExc_ConnectionResetError'),
250-
('c:data', 'PyExc_EOFError'),
251-
('c:data', 'PyExc_Exception'),
252-
('c:data', 'PyExc_FileExistsError'),
253-
('c:data', 'PyExc_FileNotFoundError'),
254-
('c:data', 'PyExc_FloatingPointError'),
255-
('c:data', 'PyExc_GeneratorExit'),
256-
('c:data', 'PyExc_ImportError'),
257-
('c:data', 'PyExc_IndentationError'),
258-
('c:data', 'PyExc_IndexError'),
259-
('c:data', 'PyExc_InterruptedError'),
260-
('c:data', 'PyExc_IsADirectoryError'),
261-
('c:data', 'PyExc_KeyboardInterrupt'),
262-
('c:data', 'PyExc_KeyError'),
263-
('c:data', 'PyExc_LookupError'),
264-
('c:data', 'PyExc_MemoryError'),
265-
('c:data', 'PyExc_ModuleNotFoundError'),
266-
('c:data', 'PyExc_NameError'),
267-
('c:data', 'PyExc_NotADirectoryError'),
268-
('c:data', 'PyExc_NotImplementedError'),
269-
('c:data', 'PyExc_OSError'),
270-
('c:data', 'PyExc_OverflowError'),
271-
('c:data', 'PyExc_PermissionError'),
272-
('c:data', 'PyExc_ProcessLookupError'),
273-
('c:data', 'PyExc_PythonFinalizationError'),
274-
('c:data', 'PyExc_RecursionError'),
275-
('c:data', 'PyExc_ReferenceError'),
276-
('c:data', 'PyExc_RuntimeError'),
277-
('c:data', 'PyExc_StopAsyncIteration'),
278-
('c:data', 'PyExc_StopIteration'),
279-
('c:data', 'PyExc_SyntaxError'),
280-
('c:data', 'PyExc_SystemError'),
281-
('c:data', 'PyExc_SystemExit'),
282-
('c:data', 'PyExc_TabError'),
283-
('c:data', 'PyExc_TimeoutError'),
284-
('c:data', 'PyExc_TypeError'),
285-
('c:data', 'PyExc_UnboundLocalError'),
286-
('c:data', 'PyExc_UnicodeDecodeError'),
287-
('c:data', 'PyExc_UnicodeEncodeError'),
288-
('c:data', 'PyExc_UnicodeError'),
289-
('c:data', 'PyExc_UnicodeTranslateError'),
290-
('c:data', 'PyExc_ValueError'),
291-
('c:data', 'PyExc_ZeroDivisionError'),
292-
# C API: Standard Python warning classes
293-
('c:data', 'PyExc_BytesWarning'),
294-
('c:data', 'PyExc_DeprecationWarning'),
295-
('c:data', 'PyExc_EncodingWarning'),
296-
('c:data', 'PyExc_FutureWarning'),
297-
('c:data', 'PyExc_ImportWarning'),
298-
('c:data', 'PyExc_PendingDeprecationWarning'),
299-
('c:data', 'PyExc_ResourceWarning'),
300-
('c:data', 'PyExc_RuntimeWarning'),
301-
('c:data', 'PyExc_SyntaxWarning'),
302-
('c:data', 'PyExc_UnicodeWarning'),
303-
('c:data', 'PyExc_UserWarning'),
304-
('c:data', 'PyExc_Warning'),
305236
# Undocumented public C macros
306237
('c:macro', 'Py_BUILD_ASSERT'),
307238
('c:macro', 'Py_BUILD_ASSERT_EXPR'),
@@ -635,13 +566,14 @@
635566
'image': '_static/og-image.png',
636567
'line_color': '#3776ab',
637568
}
638-
ogp_custom_meta_tags = [
639-
'<meta name="theme-color" content="#3776ab">',
640-
]
641-
if 'create-social-cards' not in tags: # noqa: F821
642-
# Define a static preview image when not creating social cards
643-
ogp_image = '_static/og-image.png'
644-
ogp_custom_meta_tags += [
645-
'<meta property="og:image:width" content="200">',
646-
'<meta property="og:image:height" content="200">',
569+
if 'builder_html' in tags: # noqa: F821
570+
ogp_custom_meta_tags = [
571+
'<meta name="theme-color" content="#3776ab">',
647572
]
573+
if 'create-social-cards' not in tags: # noqa: F821
574+
# Define a static preview image when not creating social cards
575+
ogp_image = '_static/og-image.png'
576+
ogp_custom_meta_tags += [
577+
'<meta property="og:image:width" content="200">',
578+
'<meta property="og:image:height" content="200">',
579+
]

Doc/glossary.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,16 @@ Glossary
12801280
and ending with double underscores. Special methods are documented in
12811281
:ref:`specialnames`.
12821282

1283+
standard library
1284+
The collection of :term:`packages <package>`, :term:`modules <module>`
1285+
and :term:`extension modules <extension module>` distributed as a part
1286+
of the official Python interpreter package. The exact membership of the
1287+
collection may vary based on platform, available system libraries, or
1288+
other criteria. Documentation can be found at :ref:`library-index`.
1289+
1290+
See also :data:`sys.stdlib_module_names` for a list of all possible
1291+
standard library module names.
1292+
12831293
statement
12841294
A statement is part of a suite (a "block" of code). A statement is either
12851295
an :term:`expression` or one of several constructs with a keyword, such
@@ -1290,6 +1300,9 @@ Glossary
12901300
issues such as incorrect types. See also :term:`type hints <type hint>`
12911301
and the :mod:`typing` module.
12921302

1303+
stdlib
1304+
An abbreviation of :term:`standard library`.
1305+
12931306
strong reference
12941307
In Python's C API, a strong reference is a reference to an object
12951308
which is owned by the code holding the reference. The strong

0 commit comments

Comments
 (0)