Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b8cbe74

Browse files
authored
bpo-39008: Require Py_ssize_t for PySys_Audit formats rather than raise a deprecation warning (GH-17540)
1 parent ac22911 commit b8cbe74

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Doc/c-api/sys.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,18 @@ accessible to C code. They all work with the current interpreter thread's
320320
arguments to this function will be consumed, using it may cause reference
321321
leaks.)
322322
323+
Note that ``#`` format characters should always be treated as
324+
``Py_ssize_t``, regardless of whether ``PY_SSIZE_T_CLEAN`` was defined.
325+
323326
:func:`sys.audit` performs the same function from Python code.
324327
325328
.. versionadded:: 3.8
326329
330+
.. versionchanged:: 3.8.2
331+
332+
Require ``Py_ssize_t`` for ``#`` format characters. Previously, an
333+
unavoidable deprecation warning was raised.
334+
327335
328336
.. c:function:: int PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
329337
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:c:func:`PySys_Audit` now requires ``Py_ssize_t`` to be used for size
2+
arguments in the format string, regardless of whethen ``PY_SSIZE_T_CLEAN``
3+
was defined at include time.

Python/sysmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ PySys_Audit(const char *event, const char *argFormat, ...)
181181
if (argFormat && argFormat[0]) {
182182
va_list args;
183183
va_start(args, argFormat);
184-
eventArgs = Py_VaBuildValue(argFormat, args);
184+
eventArgs = _Py_VaBuildValue_SizeT(argFormat, args);
185185
va_end(args);
186186
if (eventArgs && !PyTuple_Check(eventArgs)) {
187187
PyObject *argTuple = PyTuple_Pack(1, eventArgs);

0 commit comments

Comments
 (0)