Skip to content

Commit 3ad92b5

Browse files
committed
Don't specify the encoding when it's utf-8.
1 parent 02b3338 commit 3ad92b5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/websockets/frames.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def parse(cls, data: bytes) -> Close:
447447
"""
448448
if len(data) >= 2:
449449
(code,) = struct.unpack("!H", data[:2])
450-
reason = data[2:].decode("utf-8")
450+
reason = data[2:].decode()
451451
close = cls(code, reason)
452452
close.check()
453453
return close

src/websockets/legacy/protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ async def read_message(self) -> Data | None:
10361036

10371037
# Shortcut for the common case - no fragmentation
10381038
if frame.fin:
1039-
return frame.data.decode("utf-8") if text else frame.data
1039+
return frame.data.decode() if text else frame.data
10401040

10411041
# 5.4. Fragmentation
10421042
fragments: list[Data] = []

0 commit comments

Comments
 (0)