Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Simplify exception handling in is_ascii. #9985

Merged
merged 1 commit into from
May 14, 2021
Merged
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
1 change: 1 addition & 0 deletions changelog.d/9985.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Simplify a few helper functions.
4 changes: 1 addition & 3 deletions synapse/util/stringutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ def random_string_with_symbols(length: int) -> str:
def is_ascii(s: bytes) -> bool:
try:
s.decode("ascii").encode("ascii")
except UnicodeDecodeError:
return False
except UnicodeEncodeError:
except UnicodeError:
return False
return True

Expand Down