Skip to content

Commit

Permalink
Don't specify the encoding when it's utf-8.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaugustin committed Aug 7, 2024
1 parent 02b3338 commit 3ad92b5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/websockets/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/websockets/legacy/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand Down

0 comments on commit 3ad92b5

Please sign in to comment.