mailgun / talon

Apache License 2.0
1.26k stars 287 forks source link

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

Closed JimiGR1 closed 4 years ago

JimiGR1 commented 4 years ago

ERROR extracting message Traceback (most recent call last): File "C:\Users\dtr\Source\Repos\talon\talon\quotations.py", line 212, in extract_from return extract_from_html(msg_body) File "C:\Users\dtr\Source\Repos\talon\talon\quotations.py", line 429, in extract_from_html result = _extract_from_html(msg_body) File "C:\Users\dtr\Source\Repos\talon\talon\quotations.py", line 460, in _extract_from_html msg_body = re.sub(r"\<\?xml.+\?>|\<!DOCTYPE.+]>", "", msg_body) File "C:\Users\dtr\AppData\Local\Programs\Python\Python37-32\lib\site-packages\regex\regex.py", line 276, in sub endpos, concurrent, timeout) TypeError: cannot use a string pattern on a bytes-like object

Environment is Python 3.7 32-Bit.

Error occurs when calling either quotations.extract_from(html, 'text/html') or quotations.extract_from_html(html)

as the example.

chen-xiao-dong commented 4 years ago

Same issue accountered. Python 3.6.4::Anaconda,Inc Googled it may some input encode issue,since I copied this paragraph from the website as the content of html.

KazimirPodolski commented 2 years ago

@JimiGR1 how did you solve it?