mailgun / flanker

Python email address and Mime parsing library
http://www.mailgun.com
Apache License 2.0
1.63k stars 204 forks source link

Fix: TypeError: cannot use a string pattern on a bytes-like object #245

Closed chingc closed 2 years ago

chingc commented 3 years ago

Fixes #243

Python 3 will not let you do a regex match using a byte-string.


Python 3.6.8 (v3.6.8:3c6b436a57, Dec 24 2018, 02:04:31)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import re
>>> hello = re.compile('hello')
>>>
>>> hello.match(b'hello')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot use a string pattern on a bytes-like object
>>>
>>> hello.match(b'hello'.decode())
<_sre.SRE_Match object; span=(0, 5), match='hello'>
>>>
>>>
mailgun-ci commented 3 years ago

Can one of the admins verify this patch?