Skip to content

Commit ec79422

Browse files
committed
Fix formatting warnings for PyBytesWriter_Format
Add C formatting warnings and fix declaration.
1 parent c3c63ee commit ec79422

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pythoncapi_compat.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,6 +2529,9 @@ PyBytesWriter_WriteBytes(PyBytesWriter *writer,
25292529
return 0;
25302530
}
25312531

2532+
static inline int PyBytesWriter_Format(PyBytesWriter *writer, const char *format, ...)
2533+
Py_GCC_ATTRIBUTE((format(printf, 2, 0)));
2534+
25322535
static inline int
25332536
PyBytesWriter_Format(PyBytesWriter *writer, const char *format, ...)
25342537
{

tests/setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
'-Wconversion',
3535
# /usr/lib64/pypy3.7/include/pyport.h:68:20: error: redefinition of typedef
3636
# 'Py_hash_t' is a C11 feature
37-
"-Wno-typedef-redefinition",
37+
'-Wno-typedef-redefinition',
38+
# Formatting checks
39+
'-Wformat',
40+
'-Wformat-nonliteral',
41+
'-Wformat-security',
3842
))
3943
CFLAGS = COMMON_FLAGS + [
4044
# Use C99 for pythoncapi_compat.c which initializes PyModuleDef with a

0 commit comments

Comments
 (0)