diff --git a/charset_normalizer/__init__.py b/charset_normalizer/__init__.py index 596898e2..f14a90b1 100644 --- a/charset_normalizer/__init__.py +++ b/charset_normalizer/__init__.py @@ -25,9 +25,6 @@ from charset_normalizer.version import __version__, VERSION from charset_normalizer.models import CharsetMatch, CharsetMatches -# Load backport unicodedata2 if available -import charset_normalizer.hook - # Backward-compatible v1 imports from charset_normalizer.models import CharsetNormalizerMatch import charset_normalizer.api as CharsetDetector diff --git a/charset_normalizer/hook.py b/charset_normalizer/hook.py deleted file mode 100644 index ca05b213..00000000 --- a/charset_normalizer/hook.py +++ /dev/null @@ -1,7 +0,0 @@ -import sys - -try: - import unicodedata2 # type: ignore - sys.modules['unicodedata'] = unicodedata2 -except ImportError: - pass diff --git a/charset_normalizer/utils.py b/charset_normalizer/utils.py index bb433ca2..db59739f 100644 --- a/charset_normalizer/utils.py +++ b/charset_normalizer/utils.py @@ -1,4 +1,8 @@ -import unicodedata +try: + import unicodedata2 as unicodedata +except ImportError: + import unicodedata + from codecs import IncrementalDecoder from re import findall from typing import Optional, Tuple, Union, List, Set