Skip to content

Conversation

@amolenaar
Copy link
Contributor

Add C formatting warnings and fix declaration.

With extra formatting warnings, as we have in PyGObject, we get warnings like:

In file included from ../../gi/pygi-hashtable.c:21:
../../subprojects/pythoncapi-compat/pythoncapi_compat.h:2537:41: warning: format string is not a string literal [-Wformat-nonliteral]
 2537 |     PyObject *str = PyBytes_FromFormatV(format, vargs);
      |                                         ^~~~~~

This PR adds formatting warnings (errors) to the test build and addresses the format-nonliteral warning by providing an appropriate prototype for this function.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot reproduce the issue with GCC 15.2.1. What's your GCC version?

My test: run python3 runtests.py --current -v with setup.py changes.

@amolenaar
Copy link
Contributor Author

amolenaar commented Oct 3, 2025

I was testing on macOS (15) with Python 3.13.7. I suppose Clang is a bit more picky (?).

I did a (test) CI run with only the extra warnings added to setup.py, which fails .

@vstinner
Copy link
Member

vstinner commented Oct 3, 2025

I was testing on macOS (15) with Python 3.13.7. I suppose Clang is a bit more picky (?).

Ah you're using clang, ok. Using clang, I can reproduce the compiler warning.

@vstinner vstinner merged commit 97f1582 into python:main Oct 3, 2025
36 checks passed
@vstinner
Copy link
Member

vstinner commented Oct 3, 2025

Merged, thanks for the fix.

@vstinner
Copy link
Member

vstinner commented Oct 3, 2025

I'm surprised that static inline int PyUnicodeWriter_Format(PyUnicodeWriter *writer, const char *format, ...) doesn't emit a similar warning.

@amolenaar amolenaar deleted the format-errors branch October 3, 2025 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants