-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-112301: Use literal format strings in unicode_fromformat_arg #124203
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
Maybe you should add NEWS. |
This change doesn't impact end users. I don't think that a NEWS entry is needed. |
Objects/unicodeobject.c
Outdated
sprintf(buffer, fmt, va_arg(*vargs, int)) : | ||
sprintf(buffer, fmt, va_arg(*vargs, unsigned int)); | ||
break; | ||
case F_LONG: DO_SPRINTS("l", long, unsigned long) |
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.
Can you put the break
here? Something like:
case F_LONG: DO_SPRINTS("l", long, unsigned long) | |
case F_LONG: DO_SPRINTS("l", long, unsigned long); break; |
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.
OK!
One line is 85 characters now, but I think it's most readable this way.
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.
LGTM
This switches sprintf format strings in unicode_fromformat_arg to compile-time literals, avoiding
-Wformat-nonliteral
warnings and maybe even allowing optimizing thesprintf
calls.The macros aren't too readable so I'm generous with comments.
(Another option would be code generation, see the first commit.)