8000 gh-112301: Add -Wformat=2 compiler option to NODIST by nohlson · Pull Request #122474 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-112301: Add -Wformat=2 compiler option to NODIST #122474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor version _Py_InitVersion to use format string literals
  • Loading branch information
nohlson committed Aug 7, 2024
commit 8cff32e4df708d99f0b6048e919b074dd4c87d24
17 changes: 4 additions & 13 deletions Python/getversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,12 @@ void _Py_InitVersion(void)
}
initialized = 1;
#ifdef Py_GIL_DISABLED
const char *buildinfo_format = "%.80s experimental free-threading build (%.80s) %.80s";
PyOS_snprintf(version, sizeof(version), "%.80s experimental free-threading build (%.80s) %.80s",
PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler());
#else
const char *buildinfo_format = "%.80s (%.80s) %.80s";
#endif
// The format string is defined above and is observably safe.
// Ignore warnings related to non-literal format strings.
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif
PyOS_snprintf(version, sizeof(version), buildinfo_format,
PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s",
PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler());
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
}

const char *
Expand Down
0