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
16 changes: 16 additions & 0 deletions pr_body2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
In `TCPClient._create_stream`, if `IOStream()` constructor raises `OSError`, the except handler references `stream` which was never assigned:

```python
try:
stream = IOStream(socket_obj, max_buffer_size=max_buffer_size)
except OSError as e:
fu = Future()
fu.set_exception(e)
return stream, fu # NameError: 'stream' is not defined
```

This causes a `NameError` that masks the original `OSError`, making it impossible to diagnose the root cause from the traceback.

Additionally the socket object would be leaked since it's never closed in the error path.

Fixed by returning the `socket_obj` instead of the undefined `stream` variable, and closing the socket before returning.
2 changes: 1 addition & 1 deletion tornado/locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def format_date(

def format_day(
self, date: datetime.datetime, gmt_offset: int = 0, dow: bool = True
) -> bool:
) -> str:
"""Formats the given date as a day of week.

Example: "Monday, January 22". You can remove the day of week with
Expand Down