From 3ad92b50515e5c83344f0771a34e8d9e7cd8ff4e Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Wed, 7 Aug 2024 15:28:18 +0200 Subject: [PATCH] Don't specify the encoding when it's utf-8. --- src/websockets/frames.py | 2 +- src/websockets/legacy/protocol.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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] = []