tornado
tornado copied to clipboard
Fix string formatting in exception constructors across codebase
Several raise statements across the codebase pass format arguments to exception constructors using a comma instead of % operator:
# Before (comma creates a tuple message):
raise ValueError("message %s", value)
# After (proper string formatting):
raise ValueError("message %s" % value)
When Python's Exception.__init__ receives multiple arguments, str(e) shows the raw tuple representation instead of a formatted message. For example, ValueError("unsupported auth_mode %s", "digest") displays as:
ValueError: ('unsupported auth_mode %s', 'digest')
instead of:
ValueError: unsupported auth_mode digest
Affected locations:
web.py:_convert_header_value,xsrf_token,stream_request_body,_has_stream_request_bodywebsocket.py:_PerMessageDeflateCompressor.__init__,_PerMessageDeflateDecompressor.__init__,_process_server_headerssimple_httpclient.py: HTTP basic auth mode validationnetutil.py: Unix socket bind validationconcurrent.py:run_on_executorargument validation
Thanks! This looks good, but there is a black formatting error in one of the files.