-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-36020: Remove snprintf macro in pyerrors.h #20889
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
Conversation
On Windows, #include "pyerrors.h" no longer defines "snprintf" and "vsnprintf" macros. PyOS_snprintf() and PyOS_vsnprintf() should be used to get portable behavior. Replace snprintf() calls with PyOS_snprintf() and replace vsnprintf() calls with PyOS_vsnprintf().
https://docs.python.org/dev/c-api/conversion.html#c.PyOS_snprintf "PyOS_snprintf() and PyOS_vsnprintf() wrap the Standard C library functions snprintf() and vsnprintf(). Their purpose is to guarantee consistent behavior in corner cases, which the Standard C functions do not." |
Which |
The original |
This PR is about removing "snprintf" and "vsnprintf" macros from Python.h. I consider proposing a follow-up macro to deprecate PyOS_ functions and use directly snprintf() and vsnprintf() functions. But I didn't have time to dig into the history and try to understand the rationale behind these wrappers. So for now, it's safer to use PyOS_ wrappers. Currently, PyOS_vsnprintf() has a fallback implementation with this:
Maybe this code is now dead since all platforms that we support are providing vsnprintf(). My plan is first to try to remove the fallback and see if it breaks any buildbot :-) |
Ah, also, this PR is intended to land into 3.9, so I prefer to take the safest approach for this PR. For the follow-up PR, we can break stuff :-) |
I kind of disagree, because |
I reverted changes in the _decimal module. |
Thanks, I've definitely always compiled
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9. |
On Windows, GH-include "pyerrors.h" no longer defines "snprintf" and "vsnprintf" macros. PyOS_snprintf() and PyOS_vsnprintf() should be used to get portable behavior. Replace snprintf() calls with PyOS_snprintf() and replace vsnprintf() calls with PyOS_vsnprintf(). (cherry picked from commit e822e37) Co-authored-by: Victor Stinner <vstinner@python.org>
GH-20897 is a backport of this pull request to the 3.9 branch. |
On Windows, GH-include "pyerrors.h" no longer defines "snprintf" and "vsnprintf" macros. PyOS_snprintf() and PyOS_vsnprintf() should be used to get portable behavior. Replace snprintf() calls with PyOS_snprintf() and replace vsnprintf() calls with PyOS_vsnprintf(). (cherry picked from commit e822e37) Co-authored-by: Victor Stinner <vstinner@python.org>
On Windows, #include "pyerrors.h" no longer defines "snprintf" and "vsnprintf" macros. PyOS_snprintf() and PyOS_vsnprintf() should be used to get portable behavior. Replace snprintf() calls with PyOS_snprintf() and replace vsnprintf() calls with PyOS_vsnprintf().
On Windows, #include "pyerrors.h" no longer defines "snprintf" and
"vsnprintf" macros.
PyOS_snprintf() and PyOS_vsnprintf() should be used to get portable
behavior.
Replace snprintf() calls with PyOS_snprintf() and replace vsnprintf()
calls with PyOS_vsnprintf().
https://bugs.python.org/issue36020