Skip to content

Commit b2ca297

Browse files
Merge branch 'main' into ast-deprecation-warnings
2 parents dfedc35 + ee60156 commit b2ca297

File tree

105 files changed

+4307
-1642
lines changed

Some content is hidden

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

105 files changed

+4307
-1642
lines changed

Doc/c-api/code.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,51 @@ bound into a function.
115115
the free variables. On error, ``NULL`` is returned and an exception is raised.
116116
117117
.. versionadded:: 3.11
118+
119+
.. c:function:: int PyCode_AddWatcher(PyCode_WatchCallback callback)
120+
121+
Register *callback* as a code object watcher for the current interpreter.
122+
Return an ID which may be passed to :c:func:`PyCode_ClearWatcher`.
123+
In case of error (e.g. no more watcher IDs available),
124+
return ``-1`` and set an exception.
125+
126+
.. versionadded:: 3.12
127+
128+
.. c:function:: int PyCode_ClearWatcher(int watcher_id)
129+
130+
Clear watcher identified by *watcher_id* previously returned from
131+
:c:func:`PyCode_AddWatcher` for the current interpreter.
132+
Return ``0`` on success, or ``-1`` and set an exception on error
133+
(e.g. if the given *watcher_id* was never registered.)
134+
135+
.. versionadded:: 3.12
136+
137+
.. c:type:: PyCodeEvent
138+
139+
Enumeration of possible code object watcher events:
140+
- ``PY_CODE_EVENT_CREATE``
141+
- ``PY_CODE_EVENT_DESTROY``
142+
143+
.. versionadded:: 3.12
144+
145+
.. c:type:: int (*PyCode_WatchCallback)(PyCodeEvent event, PyCodeObject* co)
146+
147+
Type of a code object watcher callback function.
148+
149+
If *event* is ``PY_CODE_EVENT_CREATE``, then the callback is invoked
150+
after `co` has been fully initialized. Otherwise, the callback is invoked
151+
before the destruction of *co* takes place, so the prior state of *co*
152+
can be inspected.
153+
154+
Users of this API should not rely on internal runtime implementation
155+
details. Such details may include, but are not limited to, the exact
156+
order and timing of creation and destruction of code objects. While
157+
changes in these details may result in differences observable by watchers
158+
(including whether a callback is invoked or not), it does not change
159+
the semantics of the Python code being executed.
160+
161+
If the callback returns with an exception set, it must return ``-1``; this
162+
exception will be printed as an unraisable exception using
163+
:c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``.
164+
165+
.. versionadded:: 3.12

Doc/c-api/typeobj.rst

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,16 @@ Quick Reference
149149
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
150150

151151
.. [#slots]
152-
A slot name in parentheses indicates it is (effectively) deprecated.
153-
Names in angle brackets should be treated as read-only.
154-
Names in square brackets are for internal use only.
155-
"<R>" (as a prefix) means the field is required (must be non-``NULL``).
152+
153+
**()**: A slot name in parentheses indicates it is (effectively) deprecated.
154+
155+
**<>**: Names in angle brackets should be initially set to ``NULL`` and
156+
treated as read-only.
157+
158+
**[]**: Names in square brackets are for internal use only.
159+
160+
**<R>** (as a prefix) means the field is required (must be non-``NULL``).
161+
156162
.. [#cols] Columns:
157163
158164
**"O"**: set on :c:type:`PyBaseObject_Type`
@@ -1923,8 +1929,19 @@ and :c:type:`PyType_Type` effectively act as defaults.)
19231929
19241930
Tuple of base types.
19251931

1926-
This is set for types created by a class statement. It should be ``NULL`` for
1927-
statically defined types.
1932+
This field should be set to ``NULL`` and treated as read-only.
1933+
Python will fill it in when the type is :c:func:`initialized <PyType_Ready>`.
1934+
1935+
For dynamically created classes, the ``Py_tp_bases``
1936+
:c:type:`slot <PyType_Slot>` can be used instead of the *bases* argument
1937+
of :c:func:`PyType_FromSpecWithBases`.
1938+
The argument form is preferred.
1939+
1940+
.. warning::
1941+
1942+
Multiple inheritance does not work well for statically defined types.
1943+
If you set ``tp_bases`` to a tuple, Python will not raise an error,
1944+
but some slots will only be inherited from the first base.
19281945

19291946
**Inheritance:**
19301947

@@ -1936,6 +1953,8 @@ and :c:type:`PyType_Type` effectively act as defaults.)
19361953
Tuple containing the expanded set of base types, starting with the type itself
19371954
and ending with :class:`object`, in Method Resolution Order.
19381955

1956+
This field should be set to ``NULL`` and treated as read-only.
1957+
Python will fill it in when the type is :c:func:`initialized <PyType_Ready>`.
19391958

19401959
**Inheritance:**
19411960

Doc/library/base64.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,23 @@ The modern interface provides:
5353
Encode the :term:`bytes-like object` *s* using Base64 and return the encoded
5454
:class:`bytes`.
5555

56-
Optional *altchars* must be a :term:`bytes-like object` of at least
57-
length 2 (additional characters are ignored) which specifies an alternative
58-
alphabet for the ``+`` and ``/`` characters. This allows an application to e.g.
59-
generate URL or filesystem safe Base64 strings. The default is ``None``, for
60-
which the standard Base64 alphabet is used.
56+
Optional *altchars* must be a :term:`bytes-like object` of length 2 which
57+
specifies an alternative alphabet for the ``+`` and ``/`` characters.
58+
This allows an application to e.g. generate URL or filesystem safe Base64
59+
strings. The default is ``None``, for which the standard Base64 alphabet is used.
60+
61+
May assert or raise a a :exc:`ValueError` if the length of *altchars* is not 2. Raises a
62+
:exc:`TypeError` if *altchars* is not a :term:`bytes-like object`.
6163

6264

6365
.. function:: b64decode(s, altchars=None, validate=False)
6466

6567
Decode the Base64 encoded :term:`bytes-like object` or ASCII string
6668
*s* and return the decoded :class:`bytes`.
6769

68-
Optional *altchars* must be a :term:`bytes-like object` or ASCII string of
69-
at least length 2 (additional characters are ignored) which specifies the
70-
alternative alphabet used instead of the ``+`` and ``/`` characters.
70+
Optional *altchars* must be a :term:`bytes-like object` or ASCII string
71+
of length 2 which specifies the alternative alphabet used instead of the
72+
``+`` and ``/`` characters.
7173

7274
A :exc:`binascii.Error` exception is raised
7375
if *s* is incorrectly padded.
@@ -80,6 +82,7 @@ The modern interface provides:
8082

8183
For more information about the strict base64 check, see :func:`binascii.a2b_base64`
8284

85+
May assert or raise a :exc:`ValueError` if the length of *altchars* is not 2.
8386

8487
.. function:: standard_b64encode(s)
8588

Doc/library/ctypes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,8 +1440,8 @@ copy of the windows error code.
14401440

14411441
The *winmode* parameter is used on Windows to specify how the library is loaded
14421442
(since *mode* is ignored). It takes any value that is valid for the Win32 API
1443-
``LoadLibraryEx`` flags parameter. When omitted, the default is to use the flags
1444-
that result in the most secure DLL load to avoiding issues such as DLL
1443+
``LoadLibraryEx`` flags parameter. When omitted, the default is to use the
1444+
flags that result in the most secure DLL load, which avoids issues such as DLL
14451445
hijacking. Passing the full path to the DLL is the safest way to ensure the
14461446
correct library and dependencies are loaded.
14471447

Doc/library/fnmatch.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ patterns.
4848

4949
Also note that :func:`functools.lru_cache` with the *maxsize* of 32768 is used to
5050
cache the compiled regex patterns in the following functions: :func:`fnmatch`,
51-
:func:`fnmatchcase`, :func:`filter`.
51+
:func:`fnmatchcase`, :func:`.filter`.
5252

5353
.. function:: fnmatch(filename, pattern)
5454

0 commit comments

Comments
 (0)