Repository navigation
gh-162054: Use vsnprintf() on all platforms in PyOS_vsnprintf() #162053
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,4 @@ | ||||||
| :c:func:`PyOS_vsnprintf` now calls :c:func:`!vsnprintf` on Windows, instead of | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe even use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://peps.python.org/pep-0007/ says that Python requires C11. MSVC doesn't support C99. So if we mention a standard, it would be better to refer to C11. C11 is basically C99 without features not supported by MSVC. |
||||||
| the non-standard :c:func:`!_vsnprintf`. When the output is truncated, it now | ||||||
| returns the number of characters that would have been written, as on other | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| platforms, instead of a negative value. | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to check truncated string on the
%sargument rather than on the format string. Also, you should test the invalid format string (-1return value):Usually, we test the Python C API in test_capi. But well, there are already some PyOS_snprintf() tests in test_ctypes, so I'm ok to add a few more there.