diff --git a/src/websockets/frames.py b/src/websockets/frames.py index 0da67643..af56d3f8 100644 --- a/src/websockets/frames.py +++ b/src/websockets/frames.py @@ -447,7 +447,7 @@ def parse(cls, data: bytes) -> Close: """ if len(data) >= 2: (code,) = struct.unpack("!H", data[:2]) - reason = data[2:].decode("utf-8") + reason = data[2:].decode() close = cls(code, reason) close.check() return close diff --git a/src/websockets/legacy/protocol.py b/src/websockets/legacy/protocol.py index 57cb4e77..c28bdcf4 100644 --- a/src/websockets/legacy/protocol.py +++ b/src/websockets/legacy/protocol.py @@ -1036,7 +1036,7 @@ async def read_message(self) -> Data | None: # Shortcut for the common case - no fragmentation if frame.fin: - return frame.data.decode("utf-8") if text else frame.data + return frame.data.decode() if text else frame.data # 5.4. Fragmentation fragments: list[Data] = []