kootenpv / yagmail

Send email in Python conveniently for gmail using yagmail
MIT License
2.66k stars 265 forks source link

text_type replace str #67

Closed zhengxiaowai closed 7 years ago

zhengxiaowai commented 7 years ago

Hi Pascal van Kooten, your yagmail is awesome.

But, i send email by python2 and i insert from __future__ import unicode_literals to my file. now all string is unicode.

yagmail use isinstance(some_var, str) in many place, just like:

https://github.com/kootenpv/yagmail/blob/master/yagmail/yagmail.py#L318

str and unicode are difference in python2, so that will raise error or pass something.

i guess this "str" is a text_type, such as six.text_type. so i replace isinstance(some_var, str) to isinstance(some_var, text_type)

yagmail not ues third party library, i simulate six.text_type to create a text_type:

PY3 = sys.version_info[0] == 3
text_type = (str,) if PY3 else (str, unicode)

tests is ok in py2 or py3

kootenpv commented 7 years ago

Very professional Pull Request, thank you a lot!!!

You can see your new version from yagmail-0.6.161. To upgrade: pip install -U --no-cache yagmail