From acd86d5b1ad715794e81099517131a1dc4f0d960 Mon Sep 17 00:00:00 2001 From: Wes <5124946+wesinator@users.noreply.github.com> Date: Sat, 30 Mar 2024 15:48:06 -0400 Subject: [PATCH 1/2] Handle correct unicodedata method exception fix #6 --- homoglyphs_fork/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homoglyphs_fork/core.py b/homoglyphs_fork/core.py index 95c027e..96a557d 100644 --- a/homoglyphs_fork/core.py +++ b/homoglyphs_fork/core.py @@ -64,8 +64,8 @@ def detect(cls, char): # try detect category by unicodedata try: category = unicodedata.name(char).split()[0] - except TypeError: - # In Python2 unicodedata.name raise error for non-unicode chars + except ValueError: + # unicodedata.name raises error for non-unicode chars pass else: if category in data['aliases']: From da5096271c0a6d04528b0e7670ba1a0a482905fd Mon Sep 17 00:00:00 2001 From: Wes <5124946+wesinator@users.noreply.github.com> Date: Thu, 4 Apr 2024 23:58:33 -0400 Subject: [PATCH 2/2] handle unicodedata undocumented TypeError --- homoglyphs_fork/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homoglyphs_fork/core.py b/homoglyphs_fork/core.py index 96a557d..c50d8a2 100644 --- a/homoglyphs_fork/core.py +++ b/homoglyphs_fork/core.py @@ -64,8 +64,8 @@ def detect(cls, char): # try detect category by unicodedata try: category = unicodedata.name(char).split()[0] - except ValueError: - # unicodedata.name raises error for non-unicode chars + except (TypeError, ValueError): + # unicodedata.name raises ValueError for non-unicode chars, TypeError on empty string pass else: if category in data['aliases']: