Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from

Conversation

chingc
Copy link

@chingc chingc commented Sep 17, 2020

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
Copy link

Can one of the admins verify this patch?

@chingc chingc closed this Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: cannot use a string pattern on a bytes-like object
2 participants