-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
unhandled exception via invalid configuration #3197
base: master
Are you sure you want to change the base?
Conversation
d6eba31
to
90170c8
Compare
@washeck I saw yours and would like to leave the maintainer with the option of applying your minimal fix + test, with or without bundling more extensive changes resolving much less important (and in most instances, purely stylistic) problems. I suppose while no other steps are requested, it never hurts to review, test or discuss any of the other 99 open pull requests. |
cc0adf4
to
1289239
Compare
1289239
to
e8015d6
Compare
I agree for this but why for |
The magic happening for single-arg percent-formatting is not unique to
Agreed. Though %-formatting was never very natural to read, with arguments far away from where they go in the template. The good thing about at least using the unambiguous %-formatting is: that you can then view it in whichever form you want using automatic formatting - percent, string.format or f-string become interchangeable. |
Whenever
"string %r" % single_arg
is used, the string formatting can raise confusing exception wheneversingle_arg
is a tuple with more than one item.This is exposed via invalid configuration read from a python configuration file, or more likely and seriously because of the switched Exception argument type in 7ebe442 whenever refusing requests based on their (parsed) version tuple. The latter affecting only the case where gunicorn can receive such requests (read: not sitting behind Nginx) and only the 22.0.0 release.
Solution: Make the argument string-only again, and for good measure wrap the string argument in a tuple unconditionally, which also helps with automatically converting it to
"string {!r}".format(single_arg)
or evenf"string {single_arg!r}"
later on.