[Python-checkins] bpo-39008: Require Py_ssize_t for PySys_Audit formats rather than raise a deprecation warning (GH-17540)

Miss Islington (bot) webhook-mailer at python.org
Mon Dec 9 14:22:39 EST 2019


https://github.com/python/cpython/commit/c93d68bbb986ee0879f5627223e0bd2bb91f63dd
commit: c93d68bbb986ee0879f5627223e0bd2bb91f63dd
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-12-09T11:22:30-08:00
summary:

bpo-39008: Require Py_ssize_t for PySys_Audit formats rather than raise a deprecation warning (GH-17540)

(cherry picked from commit b8cbe74c3498c617f0e73fd0cdc5c07f2c532092)

Co-authored-by: Steve Dower <steve.dower at python.org>

files:
A Misc/NEWS.d/next/Core and Builtins/2019-12-09-10-38-51.bpo-39008.Rrp6f1.rst
M Doc/c-api/sys.rst
M Python/sysmodule.c

diff --git a/Doc/c-api/sys.rst b/Doc/c-api/sys.rst
index eccb8a67e82a5..c851ff66487d5 100644
--- a/Doc/c-api/sys.rst
+++ b/Doc/c-api/sys.rst
@@ -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)
 
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-12-09-10-38-51.bpo-39008.Rrp6f1.rst b/Misc/NEWS.d/next/Core and Builtins/2019-12-09-10-38-51.bpo-39008.Rrp6f1.rst
new file mode 100644
index 0000000000000..35237ce2714a0
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2019-12-09-10-38-51.bpo-39008.Rrp6f1.rst	
@@ -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.
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 1255665d024c3..da4b6e1a7806b 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -159,7 +159,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);



More information about the Python-checkins mailing list