Skip to content

Commit

Permalink
bpo-39008: Require Py_ssize_t for PySys_Audit formats rather than rai…
Browse files Browse the repository at this point in the history
…se a deprecation warning (GH-17540)
  • Loading branch information
zooba committed Dec 9, 2019
1 parent ac22911 commit b8cbe74
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Doc/c-api/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,18 @@ accessible to C code. They all work with the current interpreter thread's
arguments to this function will be consumed, using it may cause reference
leaks.)
Note that ``#`` format characters should always be treated as
``Py_ssize_t``, regardless of whether ``PY_SSIZE_T_CLEAN`` was defined.
:func:`sys.audit` performs the same function from Python code.
.. versionadded:: 3.8
.. versionchanged:: 3.8.2
Require ``Py_ssize_t`` for ``#`` format characters. Previously, an
unavoidable deprecation warning was raised.
.. c:function:: int PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:c:func:`PySys_Audit` now requires ``Py_ssize_t`` to be used for size
arguments in the format string, regardless of whethen ``PY_SSIZE_T_CLEAN``
was defined at include time.
2 changes: 1 addition & 1 deletion Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ PySys_Audit(const char *event, const char *argFormat, ...)
if (argFormat && argFormat[0]) {
va_list args;
va_start(args, argFormat);
eventArgs = Py_VaBuildValue(argFormat, args);
eventArgs = _Py_VaBuildValue_SizeT(argFormat, args);
va_end(args);
if (eventArgs && !PyTuple_Check(eventArgs)) {
PyObject *argTuple = PyTuple_Pack(1, eventArgs);
Expand Down

0 comments on commit b8cbe74

Please sign in to comment.