These three functions in emails/utils.py are Python 2 compatibility wrappers:
to_native(x) — if bytes, decode to str; otherwise return as-is
to_unicode(x) — same, plus str(x) for non-str/bytes
to_bytes(x) — if str, encode to bytes; otherwise return as-is
On Python 3 they are trivial wrappers around .encode() / .decode(). They were already removed from message.py, signers.py, and utils.py itself in #194. Remaining call sites:
emails/loader/ (helpers.py, local_store.py, __init__.py)
emails/transformer.py
emails/store/file.py (to_bytes only)
Each call can be replaced with direct .encode() / .decode() / isinstance check. Once all call sites are migrated, the functions and their overloads can be removed from utils.py.
These three functions in
emails/utils.pyare Python 2 compatibility wrappers:to_native(x)— if bytes, decode to str; otherwise return as-isto_unicode(x)— same, plusstr(x)for non-str/bytesto_bytes(x)— if str, encode to bytes; otherwise return as-isOn Python 3 they are trivial wrappers around
.encode()/.decode(). They were already removed frommessage.py,signers.py, andutils.pyitself in #194. Remaining call sites:emails/loader/(helpers.py, local_store.py,__init__.py)emails/transformer.pyemails/store/file.py(to_bytesonly)Each call can be replaced with direct
.encode()/.decode()/isinstancecheck. Once all call sites are migrated, the functions and their overloads can be removed fromutils.py.