From ab343afbb5023db1102594f5dc1950f5bafbbee0 Mon Sep 17 00:00:00 2001 From: Arjan Molenaar Date: Fri, 3 Oct 2025 11:16:18 +0200 Subject: [PATCH 1/2] Add C formatting warning --- tests/setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/setup.py b/tests/setup.py index 825241e..33a0e66 100755 --- a/tests/setup.py +++ b/tests/setup.py @@ -34,7 +34,11 @@ '-Wconversion', # /usr/lib64/pypy3.7/include/pyport.h:68:20: error: redefinition of typedef # 'Py_hash_t' is a C11 feature - "-Wno-typedef-redefinition", + '-Wno-typedef-redefinition', + # Formatting checks + '-Wformat', + '-Wformat-nonliteral', + '-Wformat-security', )) CFLAGS = COMMON_FLAGS + [ # Use C99 for pythoncapi_compat.c which initializes PyModuleDef with a From a2f694475f73644f66ae8ab75bd7136025f193e4 Mon Sep 17 00:00:00 2001 From: Arjan Molenaar Date: Fri, 3 Oct 2025 11:17:23 +0200 Subject: [PATCH 2/2] Add prototype for PyBytesWriter_Format --- pythoncapi_compat.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pythoncapi_compat.h b/pythoncapi_compat.h index ecc445e..791d511 100644 --- a/pythoncapi_compat.h +++ b/pythoncapi_compat.h @@ -2529,6 +2529,10 @@ PyBytesWriter_WriteBytes(PyBytesWriter *writer, return 0; } +static inline int +PyBytesWriter_Format(PyBytesWriter *writer, const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 2, 0))); + static inline int PyBytesWriter_Format(PyBytesWriter *writer, const char *format, ...) {