Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions pr_body.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Several `raise` statements across the codebase pass format arguments to exception constructors using a comma instead of `%` operator:

```python
# 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_body`
- `websocket.py`: `_PerMessageDeflateCompressor.__init__`, `_PerMessageDeflateDecompressor.__init__`, `_process_server_headers`
- `simple_httpclient.py`: HTTP basic auth mode validation
- `netutil.py`: Unix socket bind validation
- `concurrent.py`: `run_on_executor` argument validation
3 changes: 2 additions & 1 deletion tornado/tcpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def _create_stream(
except OSError as e:
fu = Future() # type: Future[IOStream]
fu.set_exception(e)
return stream, fu
socket_obj.close()
return socket_obj, fu
else:
return stream, stream.connect(addr)