Skip to content

Commit 08735b2

Browse files
authored
Merge branch 'main' into clarify-sys.monitoring
2 parents 37fde1b + 96905bd commit 08735b2

File tree

571 files changed

+17390
-8530
lines changed

Some content is hidden

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

571 files changed

+17390
-8530
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*.ico binary
1111
*.jpg binary
1212
*.pck binary
13+
*.pdf binary
1314
*.png binary
1415
*.psd binary
1516
*.tar binary
@@ -67,6 +68,7 @@ PCbuild/readme.txt dos
6768
**/clinic/*.cpp.h generated
6869
**/clinic/*.h.h generated
6970
*_db.h generated
71+
Doc/c-api/lifecycle.dot.svg generated
7072
Doc/data/stable_abi.dat generated
7173
Doc/library/token-list.inc generated
7274
Include/internal/pycore_ast.h generated

.github/CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,8 @@ Modules/_xxtestfuzz/ @ammaraskar
331331
**/*templateobject* @lysnikolaou
332332
**/*templatelib* @lysnikolaou
333333
**/*tstring* @lysnikolaou
334+
335+
# Remote debugging
336+
Python/remote_debug.h @pablogsal
337+
Python/remote_debugging.c @pablogsal
338+
Modules/_remote_debugging_module.c @pablogsal @ambv @1st1

.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ permissions:
1515
contents: read
1616

1717
concurrency:
18-
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-reusable
18+
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#concurrency
19+
# 'group' must be a key uniquely representing a PR or push event.
20+
# github.workflow is the workflow name
21+
# github.actor is the user invoking the workflow
22+
# github.head_ref is the source branch of the PR or otherwise blank
23+
# github.run_id is a unique number for the current run
24+
group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }}
1925
cancel-in-progress: true
2026

2127
env:

.github/workflows/mypy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ on:
1414
- "Lib/tomllib/**"
1515
- "Misc/mypy/**"
1616
- "Tools/build/compute-changes.py"
17+
- "Tools/build/deepfreeze.py"
1718
- "Tools/build/generate_sbom.py"
1819
- "Tools/build/generate-build-details.py"
1920
- "Tools/build/verify_ensurepip_wheels.py"
2021
- "Tools/build/update_file.py"
22+
- "Tools/build/umarshal.py"
2123
- "Tools/cases_generator/**"
2224
- "Tools/clinic/**"
2325
- "Tools/jit/**"

.github/workflows/reusable-context.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ jobs:
9797
run: python Tools/build/compute-changes.py
9898
env:
9999
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
100+
GITHUB_EVENT_NAME: ${{ github.event_name }}
100101
CCF_TARGET_REF: ${{ github.base_ref || github.event.repository.default_branch }}
101102
CCF_HEAD_REF: ${{ github.event.pull_request.head.sha || github.sha }}
102103

.github/workflows/tail-call.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,3 @@ jobs:
137137
CC=clang-20 ./configure --with-tail-call-interp --disable-gil
138138
make all --jobs 4
139139
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
140-

.pre-commit-config.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ repos:
4343
exclude: ^Lib/test/test_tomllib/
4444
- id: check-yaml
4545
- id: end-of-file-fixer
46-
types: [python]
46+
types_or: [python, yaml]
4747
exclude: Lib/test/tokenizedata/coding20731.py
48+
- id: end-of-file-fixer
49+
files: '^\.github/CODEOWNERS$'
50+
- id: trailing-whitespace
51+
types_or: [c, inc, python, rst, yaml]
4852
- id: trailing-whitespace
49-
types_or: [c, inc, python, rst]
53+
files: '^\.github/CODEOWNERS|\.(gram)$'
5054

5155
- repo: https://github.com/python-jsonschema/check-jsonschema
5256
rev: 0.33.0

.readthedocs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@ build:
3232
- make -C Doc venv html
3333
- mkdir _readthedocs
3434
- mv Doc/build/html _readthedocs/html
35-

Doc/c-api/allocation.rst

Lines changed: 107 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,128 @@ Allocating Objects on the Heap
1616
1717
Initialize a newly allocated object *op* with its type and initial
1818
reference. Returns the initialized object. Other fields of the object are
19-
not affected.
19+
not initialized. Despite its name, this function is unrelated to the
20+
object's :meth:`~object.__init__` method (:c:member:`~PyTypeObject.tp_init`
21+
slot). Specifically, this function does **not** call the object's
22+
:meth:`!__init__` method.
23+
24+
In general, consider this function to be a low-level routine. Use
25+
:c:member:`~PyTypeObject.tp_alloc` where possible.
26+
For implementing :c:member:`!tp_alloc` for your type, prefer
27+
:c:func:`PyType_GenericAlloc` or :c:func:`PyObject_New`.
28+
29+
.. note::
30+
31+
This function only initializes the object's memory corresponding to the
32+
initial :c:type:`PyObject` structure. It does not zero the rest.
2033
2134
2235
.. c:function:: PyVarObject* PyObject_InitVar(PyVarObject *op, PyTypeObject *type, Py_ssize_t size)
2336
2437
This does everything :c:func:`PyObject_Init` does, and also initializes the
2538
length information for a variable-size object.
2639
40+
.. note::
41+
42+
This function only initializes some of the object's memory. It does not
43+
zero the rest.
44+
2745
2846
.. c:macro:: PyObject_New(TYPE, typeobj)
2947
30-
Allocate a new Python object using the C structure type *TYPE*
31-
and the Python type object *typeobj* (``PyTypeObject*``).
32-
Fields not defined by the Python object header are not initialized.
33-
The caller will own the only reference to the object
34-
(i.e. its reference count will be one).
35-
The size of the memory allocation is determined from the
36-
:c:member:`~PyTypeObject.tp_basicsize` field of the type object.
48+
Allocates a new Python object using the C structure type *TYPE* and the
49+
Python type object *typeobj* (``PyTypeObject*``) by calling
50+
:c:func:`PyObject_Malloc` to allocate memory and initializing it like
51+
:c:func:`PyObject_Init`. The caller will own the only reference to the
52+
object (i.e. its reference count will be one).
53+
54+
Avoid calling this directly to allocate memory for an object; call the type's
55+
:c:member:`~PyTypeObject.tp_alloc` slot instead.
56+
57+
When populating a type's :c:member:`~PyTypeObject.tp_alloc` slot,
58+
:c:func:`PyType_GenericAlloc` is preferred over a custom function that
59+
simply calls this macro.
60+
61+
This macro does not call :c:member:`~PyTypeObject.tp_alloc`,
62+
:c:member:`~PyTypeObject.tp_new` (:meth:`~object.__new__`), or
63+
:c:member:`~PyTypeObject.tp_init` (:meth:`~object.__init__`).
64+
65+
This cannot be used for objects with :c:macro:`Py_TPFLAGS_HAVE_GC` set in
66+
:c:member:`~PyTypeObject.tp_flags`; use :c:macro:`PyObject_GC_New` instead.
67+
68+
Memory allocated by this macro must be freed with :c:func:`PyObject_Free`
69+
(usually called via the object's :c:member:`~PyTypeObject.tp_free` slot).
70+
71+
.. note::
72+
73+
The returned memory is not guaranteed to have been completely zeroed
74+
before it was initialized.
75+
76+
.. note::
77+
78+
This macro does not construct a fully initialized object of the given
79+
type; it merely allocates memory and prepares it for further
80+
initialization by :c:member:`~PyTypeObject.tp_init`. To construct a
81+
fully initialized object, call *typeobj* instead. For example::
3782
38-
Note that this function is unsuitable if *typeobj* has
39-
:c:macro:`Py_TPFLAGS_HAVE_GC` set. For such objects,
40-
use :c:func:`PyObject_GC_New` instead.
83+
PyObject *foo = PyObject_CallNoArgs((PyObject *)&PyFoo_Type);
84+
85+
.. seealso::
86+
87+
* :c:func:`PyObject_Free`
88+
* :c:macro:`PyObject_GC_New`
89+
* :c:func:`PyType_GenericAlloc`
90+
* :c:member:`~PyTypeObject.tp_alloc`
4191

4292

4393
.. c:macro:: PyObject_NewVar(TYPE, typeobj, size)
4494
45-
Allocate a new Python object using the C structure type *TYPE* and the
46-
Python type object *typeobj* (``PyTypeObject*``).
47-
Fields not defined by the Python object header
48-
are not initialized. The allocated memory allows for the *TYPE* structure
49-
plus *size* (``Py_ssize_t``) fields of the size
50-
given by the :c:member:`~PyTypeObject.tp_itemsize` field of
51-
*typeobj*. This is useful for implementing objects like tuples, which are
52-
able to determine their size at construction time. Embedding the array of
53-
fields into the same allocation decreases the number of allocations,
54-
improving the memory management efficiency.
95+
Like :c:macro:`PyObject_New` except:
96+
97+
* It allocates enough memory for the *TYPE* structure plus *size*
98+
(``Py_ssize_t``) fields of the size given by the
99+
:c:member:`~PyTypeObject.tp_itemsize` field of *typeobj*.
100+
* The memory is initialized like :c:func:`PyObject_InitVar`.
101+
102+
This is useful for implementing objects like tuples, which are able to
103+
determine their size at construction time. Embedding the array of fields
104+
into the same allocation decreases the number of allocations, improving the
105+
memory management efficiency.
106+
107+
Avoid calling this directly to allocate memory for an object; call the type's
108+
:c:member:`~PyTypeObject.tp_alloc` slot instead.
109+
110+
When populating a type's :c:member:`~PyTypeObject.tp_alloc` slot,
111+
:c:func:`PyType_GenericAlloc` is preferred over a custom function that
112+
simply calls this macro.
113+
114+
This cannot be used for objects with :c:macro:`Py_TPFLAGS_HAVE_GC` set in
115+
:c:member:`~PyTypeObject.tp_flags`; use :c:macro:`PyObject_GC_NewVar`
116+
instead.
117+
118+
Memory allocated by this function must be freed with :c:func:`PyObject_Free`
119+
(usually called via the object's :c:member:`~PyTypeObject.tp_free` slot).
120+
121+
.. note::
122+
123+
The returned memory is not guaranteed to have been completely zeroed
124+
before it was initialized.
125+
126+
.. note::
127+
128+
This macro does not construct a fully initialized object of the given
129+
type; it merely allocates memory and prepares it for further
130+
initialization by :c:member:`~PyTypeObject.tp_init`. To construct a
131+
fully initialized object, call *typeobj* instead. For example::
132+
133+
PyObject *list_instance = PyObject_CallNoArgs((PyObject *)&PyList_Type);
134+
135+
.. seealso::
55136

56-
Note that this function is unsuitable if *typeobj* has
57-
:c:macro:`Py_TPFLAGS_HAVE_GC` set. For such objects,
58-
use :c:func:`PyObject_GC_NewVar` instead.
137+
* :c:func:`PyObject_Free`
138+
* :c:macro:`PyObject_GC_NewVar`
139+
* :c:func:`PyType_GenericAlloc`
140+
* :c:member:`~PyTypeObject.tp_alloc`
59141

60142

61143
.. c:function:: void PyObject_Del(void *op)
@@ -71,6 +153,6 @@ Allocating Objects on the Heap
71153
72154
.. seealso::
73155
74-
:c:func:`PyModule_Create`
156+
:ref:`moduleobjects`
75157
To allocate and create extension modules.
76158

Doc/c-api/code.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ bound into a function.
182182
Type of a code object watcher callback function.
183183
184184
If *event* is ``PY_CODE_EVENT_CREATE``, then the callback is invoked
185-
after `co` has been fully initialized. Otherwise, the callback is invoked
185+
after *co* has been fully initialized. Otherwise, the callback is invoked
186186
before the destruction of *co* takes place, so the prior state of *co*
187187
can be inspected.
188188

0 commit comments

Comments
 (0)