Skip to content

Commit

Permalink
Don't decode if it's already a string
Browse files Browse the repository at this point in the history
  • Loading branch information
wlach committed May 20, 2024
1 parent 5a8f108 commit c3a5858
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion flask_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ def force_text(s, encoding="utf-8", errors="strict"):
Similar to smart_text, except that lazy instances are resolved to
strings, rather than kept as lazy objects.
"""
if isinstance(s, str):
return s

try:
if isinstance(s, str):
s = s.decode(encoding, errors)
return s
elif isinstance(s, bytes):
s = str(s, encoding, errors)
else:
Expand Down

0 comments on commit c3a5858

Please sign in to comment.