We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 31fc308 commit a727aa8Copy full SHA for a727aa8
py4web/utils/mailer.py
@@ -55,7 +55,7 @@ def to_bytes(text, encoding="utf8"):
55
# if the text is not a string or bytes, maybe it is a file
56
if text is None:
57
text = b""
58
- if not isinstance(text, (str, bytes)):
+ elif hasattr(text, "read") and callable(text.read):
59
text = text.read()
60
# if it is a unicode string encode it
61
if isinstance(text, str):
@@ -73,7 +73,7 @@ def to_unicode(text, encoding="utf8"):
73
74
75
text = ""
76
- elif not isinstance(text, (str, bytes)):
77
78
# if it is a bytes string encode it
79
if isinstance(text, bytes):
0 commit comments