Skip to content

Commit

Permalink
update util function for parse-bool
Browse files Browse the repository at this point in the history
Signed-off-by: hirokuni-kitahara <[email protected]>
  • Loading branch information
hirokuni-kitahara committed May 7, 2024
1 parent a95a453 commit 9cb72a8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ansible_risk_insight/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
except LookupError:
_has_surrogateescape = False

_surrogate_error_handlers = frozenset((None, "surrogate_or_replace", "surrogate_or_strict", "surrogate_then_replace"))
_surrogate_errors = frozenset((None, "surrogate_or_replace", "surrogate_or_strict", "surrogate_then_replace"))


def lock_file(fpath, timeout=10):
Expand Down Expand Up @@ -759,7 +759,7 @@ def to_str(obj, encoding="utf-8", errors=None):
if isinstance(obj, str):
return obj

if errors in _surrogate_error_handlers:
if errors in _surrogate_errors:
if _has_surrogateescape:
errors = "surrogateescape"
elif errors == "surrogate_or_strict":
Expand All @@ -776,7 +776,6 @@ def to_str(obj, encoding="utf-8", errors=None):
try:
value = repr(obj)
except UnicodeError:
# Giving up
return ""

return to_str(value, encoding, errors)
Expand Down

0 comments on commit 9cb72a8

Please sign in to comment.