Skip to content

Commit e250ed3

Browse files
committed
Deploying to gh-pages from @ b70d162 🚀
1 parent fc075c9 commit e250ed3

File tree

768 files changed

+37339
-37335
lines changed

Some content is hidden

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

768 files changed

+37339
-37335
lines changed

.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 908a2225ab805924400df1aecc1bf46b
3+
config: bdfb3041d251008c4c431e304e0b21c1
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

_sources/c-api/arg.rst.txt

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -152,48 +152,6 @@ There are three ways strings and buffers can be converted to C:
152152
attempting any conversion. Raises :exc:`TypeError` if the object is not
153153
a :class:`bytearray` object. The C variable may also be declared as :c:expr:`PyObject*`.
154154

155-
``u`` (:class:`str`) [const Py_UNICODE \*]
156-
Convert a Python Unicode object to a C pointer to a NUL-terminated buffer of
157-
Unicode characters. You must pass the address of a :c:type:`Py_UNICODE`
158-
pointer variable, which will be filled with the pointer to an existing
159-
Unicode buffer. Please note that the width of a :c:type:`Py_UNICODE`
160-
character depends on compilation options (it is either 16 or 32 bits).
161-
The Python string must not contain embedded null code points; if it does,
162-
a :exc:`ValueError` exception is raised.
163-
164-
.. versionchanged:: 3.5
165-
Previously, :exc:`TypeError` was raised when embedded null code points
166-
were encountered in the Python string.
167-
168-
.. deprecated-removed:: 3.3 3.12
169-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
170-
:c:func:`PyUnicode_AsWideCharString`.
171-
172-
``u#`` (:class:`str`) [const Py_UNICODE \*, :c:type:`Py_ssize_t`]
173-
This variant on ``u`` stores into two C variables, the first one a pointer to a
174-
Unicode data buffer, the second one its length. This variant allows
175-
null code points.
176-
177-
.. deprecated-removed:: 3.3 3.12
178-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
179-
:c:func:`PyUnicode_AsWideCharString`.
180-
181-
``Z`` (:class:`str` or ``None``) [const Py_UNICODE \*]
182-
Like ``u``, but the Python object may also be ``None``, in which case the
183-
:c:type:`Py_UNICODE` pointer is set to ``NULL``.
184-
185-
.. deprecated-removed:: 3.3 3.12
186-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
187-
:c:func:`PyUnicode_AsWideCharString`.
188-
189-
``Z#`` (:class:`str` or ``None``) [const Py_UNICODE \*, :c:type:`Py_ssize_t`]
190-
Like ``u#``, but the Python object may also be ``None``, in which case the
191-
:c:type:`Py_UNICODE` pointer is set to ``NULL``.
192-
193-
.. deprecated-removed:: 3.3 3.12
194-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
195-
:c:func:`PyUnicode_AsWideCharString`.
196-
197155
``U`` (:class:`str`) [PyObject \*]
198156
Requires that the Python object is a Unicode object, without attempting
199157
any conversion. Raises :exc:`TypeError` if the object is not a Unicode
@@ -263,6 +221,11 @@ There are three ways strings and buffers can be converted to C:
263221
them. Instead, the implementation assumes that the byte string object uses the
264222
encoding passed in as parameter.
265223

224+
.. versionchanged:: 3.12
225+
``u``, ``u#``, ``Z``, and ``Z#`` are removed because they used a legacy
226+
``Py_UNICODE*`` representation.
227+
228+
266229
Numbers
267230
-------
268231

_sources/c-api/bool.rst.txt

Lines changed: 14 additions & 11 deletions
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*.

_sources/c-api/bytes.rst.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ called with a non-bytes parameter.
5858
5959
.. % XXX: This should be exactly the same as the table in PyErr_Format.
6060
.. % One should just refer to the other.
61-
.. % XXX: The descriptions for %zd and %zu are wrong, but the truth is complicated
62-
.. % because not all compilers support the %z width modifier -- we fake it
63-
.. % when necessary via interpolating PY_FORMAT_SIZE_T.
6461
6562
.. tabularcolumns:: |l|l|L|
6663

_sources/c-api/call.rst.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ This bears repeating:
5757
A class supporting vectorcall **must** also implement
5858
:c:member:`~PyTypeObject.tp_call` with the same semantics.
5959

60+
.. versionchanged:: 3.12
61+
62+
The :const:`Py_TPFLAGS_HAVE_VECTORCALL` flag is now removed from a class
63+
when the class's :py:meth:`~object.__call__` method is reassigned.
64+
(This internally sets :c:member:`~PyTypeObject.tp_call` only, and thus
65+
may make it behave differently than the vectorcall function.)
66+
In earlier Python versions, vectorcall should only be used with
67+
:const:`immutable <Py_TPFLAGS_IMMUTABLETYPE>` or static types.
68+
6069
A class should not implement vectorcall if that would be slower
6170
than *tp_call*. For example, if the callee needs to convert
6271
the arguments to an args tuple and kwargs dict anyway, then there is no point
@@ -84,7 +93,7 @@ This is a pointer to a function with the following signature:
8493
and they must be unique.
8594
If there are no keyword arguments, then *kwnames* can instead be *NULL*.
8695

87-
.. c:macro:: PY_VECTORCALL_ARGUMENTS_OFFSET
96+
.. data:: PY_VECTORCALL_ARGUMENTS_OFFSET
8897

8998
If this flag is set in a vectorcall *nargsf* argument, the callee is allowed
9099
to temporarily change ``args[-1]``. In other words, *args* points to

_sources/c-api/code.rst.txt

Lines changed: 151 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,47 @@ bound into a function.
3333
3434
Return the number of free variables in *co*.
3535
36-
.. c:function:: PyCodeObject* PyCode_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
36+
.. c:function:: PyCodeObject* PyUnstable_Code_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
3737
3838
Return a new code object. If you need a dummy code object to create a frame,
39-
use :c:func:`PyCode_NewEmpty` instead. Calling :c:func:`PyCode_New` directly
40-
will bind you to a precise Python version since the definition of the bytecode
41-
changes often. The many arguments of this function are inter-dependent in complex
39+
use :c:func:`PyCode_NewEmpty` instead.
40+
41+
Since the definition of the bytecode changes often, calling
42+
:c:func:`PyCode_New` directly can bind you to a precise Python version.
43+
44+
The many arguments of this function are inter-dependent in complex
4245
ways, meaning that subtle changes to values are likely to result in incorrect
4346
execution or VM crashes. Use this function only with extreme care.
4447
4548
.. versionchanged:: 3.11
4649
Added ``exceptiontable`` parameter.
4750
48-
.. c:function:: PyCodeObject* PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
51+
.. index:: single: PyCode_New
52+
53+
.. versionchanged:: 3.12
54+
55+
Renamed from ``PyCode_New`` as part of :ref:`unstable-c-api`.
56+
The old name is deprecated, but will remain available until the
57+
signature changes again.
58+
59+
.. c:function:: PyCodeObject* PyUnstable_Code_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
4960
5061
Similar to :c:func:`PyCode_New`, but with an extra "posonlyargcount" for positional-only arguments.
5162
The same caveats that apply to ``PyCode_New`` also apply to this function.
5263
53-
.. versionadded:: 3.8
64+
.. index:: single: PyCode_NewWithPosOnlyArgs
65+
66+
.. versionadded:: 3.8 as ``PyCode_NewWithPosOnlyArgs``
5467
5568
.. versionchanged:: 3.11
5669
Added ``exceptiontable`` parameter.
5770
71+
.. versionchanged:: 3.12
72+
73+
Renamed to ``PyUnstable_Code_NewWithPosOnlyArgs``.
74+
The old name is deprecated, but will remain available until the
75+
signature changes again.
76+
5877
.. c:function:: PyCodeObject* PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
5978
6079
Return a new empty code object with the specified filename,
@@ -117,3 +136,129 @@ bound into a function.
117136
the free variables. On error, ``NULL`` is returned and an exception is raised.
118137
119138
.. versionadded:: 3.11
139+
140+
.. c:function:: int PyCode_AddWatcher(PyCode_WatchCallback callback)
141+
142+
Register *callback* as a code object watcher for the current interpreter.
143+
Return an ID which may be passed to :c:func:`PyCode_ClearWatcher`.
144+
In case of error (e.g. no more watcher IDs available),
145+
return ``-1`` and set an exception.
146+
147+
.. versionadded:: 3.12
148+
149+
.. c:function:: int PyCode_ClearWatcher(int watcher_id)
150+
151+
Clear watcher identified by *watcher_id* previously returned from
152+
:c:func:`PyCode_AddWatcher` for the current interpreter.
153+
Return ``0`` on success, or ``-1`` and set an exception on error
154+
(e.g. if the given *watcher_id* was never registered.)
155+
156+
.. versionadded:: 3.12
157+
158+
.. c:type:: PyCodeEvent
159+
160+
Enumeration of possible code object watcher events:
161+
- ``PY_CODE_EVENT_CREATE``
162+
- ``PY_CODE_EVENT_DESTROY``
163+
164+
.. versionadded:: 3.12
165+
166+
.. c:type:: int (*PyCode_WatchCallback)(PyCodeEvent event, PyCodeObject* co)
167+
168+
Type of a code object watcher callback function.
169+
170+
If *event* is ``PY_CODE_EVENT_CREATE``, then the callback is invoked
171+
after `co` has been fully initialized. Otherwise, the callback is invoked
172+
before the destruction of *co* takes place, so the prior state of *co*
173+
can be inspected.
174+
175+
If *event* is ``PY_CODE_EVENT_DESTROY``, taking a reference in the callback
176+
to the about-to-be-destroyed code object will resurrect it and prevent it
177+
from being freed at this time. When the resurrected object is destroyed
178+
later, any watcher callbacks active at that time will be called again.
179+
180+
Users of this API should not rely on internal runtime implementation
181+
details. Such details may include, but are not limited to, the exact
182+
order and timing of creation and destruction of code objects. While
183+
changes in these details may result in differences observable by watchers
184+
(including whether a callback is invoked or not), it does not change
185+
the semantics of the Python code being executed.
186+
187+
If the callback sets an exception, it must return ``-1``; this exception will
188+
be printed as an unraisable exception using :c:func:`PyErr_WriteUnraisable`.
189+
Otherwise it should return ``0``.
190+
191+
There may already be a pending exception set on entry to the callback. In
192+
this case, the callback should return ``0`` with the same exception still
193+
set. This means the callback may not call any other API that can set an
194+
exception unless it saves and clears the exception state first, and restores
195+
it before returning.
196+
197+
.. versionadded:: 3.12
198+
199+
200+
Extra information
201+
-----------------
202+
203+
To support low-level extensions to frame evaluation, such as external
204+
just-in-time compilers, it is possible to attach arbitrary extra data to
205+
code objects.
206+
207+
These functions are part of the unstable C API tier:
208+
this functionality is a CPython implementation detail, and the API
209+
may change without deprecation warnings.
210+
211+
.. c:function:: Py_ssize_t PyUnstable_Eval_RequestCodeExtraIndex(freefunc free)
212+
213+
Return a new an opaque index value used to adding data to code objects.
214+
215+
You generally call this function once (per interpreter) and use the result
216+
with ``PyCode_GetExtra`` and ``PyCode_SetExtra`` to manipulate
217+
data on individual code objects.
218+
219+
If *free* is not ``NULL``: when a code object is deallocated,
220+
*free* will be called on non-``NULL`` data stored under the new index.
221+
Use :c:func:`Py_DecRef` when storing :c:type:`PyObject`.
222+
223+
.. index:: single: _PyEval_RequestCodeExtraIndex
224+
225+
.. versionadded:: 3.6 as ``_PyEval_RequestCodeExtraIndex``
226+
227+
.. versionchanged:: 3.12
228+
229+
Renamed to ``PyUnstable_Eval_RequestCodeExtraIndex``.
230+
The old private name is deprecated, but will be available until the API
231+
changes.
232+
233+
.. c:function:: int PyUnstable_Code_GetExtra(PyObject *code, Py_ssize_t index, void **extra)
234+
235+
Set *extra* to the extra data stored under the given index.
236+
Return 0 on success. Set an exception and return -1 on failure.
237+
238+
If no data was set under the index, set *extra* to ``NULL`` and return
239+
0 without setting an exception.
240+
241+
.. index:: single: _PyCode_GetExtra
242+
243+
.. versionadded:: 3.6 as ``_PyCode_GetExtra``
244+
245+
.. versionchanged:: 3.12
246+
247+
Renamed to ``PyUnstable_Code_GetExtra``.
248+
The old private name is deprecated, but will be available until the API
249+
changes.
250+
251+
.. c:function:: int PyUnstable_Code_SetExtra(PyObject *code, Py_ssize_t index, void *extra)
252+
253+
Set the extra data stored under the given index to *extra*.
254+
Return 0 on success. Set an exception and return -1 on failure.
255+
256+
.. index:: single: _PyCode_SetExtra
257+
258+
.. versionadded:: 3.6 as ``_PyCode_SetExtra``
259+
260+
.. versionchanged:: 3.12
261+
262+
Renamed to ``PyUnstable_Code_SetExtra``.
263+
The old private name is deprecated, but will be available until the API
264+
changes.

0 commit comments

Comments
 (0)