Skip to content

Commit

Permalink
Rely on ExceptionTrap.passes for testing decodable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Oct 31, 2021
1 parent 3a82a4d commit 139ef36
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions jaraco/text/__init__.py
Expand Up @@ -8,8 +8,8 @@
except ImportError: # pragma: nocover
from importlib_resources import files # type: ignore

from jaraco.functools import compose, method_cache, apply
from jaraco.context import suppress
from jaraco.functools import compose, method_cache
from jaraco.context import ExceptionTrap


def substitution(old, new):
Expand Down Expand Up @@ -129,8 +129,11 @@ def split(self, splitter=' ', maxsplit=0):
return pattern.split(self, maxsplit)


@apply(bool)
@suppress(UnicodeDecodeError)
# Python 3.8 compatibility
_unicode_trap = ExceptionTrap(UnicodeDecodeError)


@_unicode_trap.passes
def is_decodable(value):
r"""
Return True if the supplied value is decodable (using the default
Expand All @@ -142,7 +145,6 @@ def is_decodable(value):
True
"""
value.decode()
return True


def is_binary(value):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -18,7 +18,7 @@ include_package_data = true
python_requires = >=3.6
install_requires =
jaraco.functools
jaraco.context
jaraco.context >= 4.1
importlib_resources; python_version < "3.9"

[options.packages.find]
Expand Down

0 comments on commit 139ef36

Please sign in to comment.