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

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

Open
AjayKumar2916 opened this issue Jun 15, 2020 · 6 comments
Open

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

AjayKumar2916 opened this issue Jun 15, 2020 · 6 comments

Comments

@AjayKumar2916
Copy link

Python version 3.7.7
flanker version 0.9.11

from flanker.addresslib import address                                                                                                                                                                                           

address.validate_address(<custom domaian email address>)  
----> 1 address.validate_address('custom domaian email address')

~/.virtualenvs/newvenv/lib/python3.7/site-packages/flanker/utils.py in wrapper(*args, **kwargs)
     62         @wraps(f)
     63         def wrapper(*args, **kwargs):
---> 64             return_value = f(*args, **kwargs)
     65             if 'metrics' in kwargs and kwargs['metrics'] == True:
     66                 #return all values

~/.virtualenvs/newvenv/lib/python3.7/site-packages/flanker/addresslib/address.py in validate_address(addr_spec, metrics, skip_remote_checks)
    321     # lookup custom local-part grammar if it exists
    322     bstart = time()
--> 323     plugin = plugin_for_esp(exchanger)
    324     mtimes['custom_grammar'] = time() - bstart
    325     if plugin and plugin.validate(paddr) is False:

~/.virtualenvs/newvenv/lib/python3.7/site-packages/flanker/addresslib/validate.py in plugin_for_esp(mail_exchanger)
    127     """
    128     for grammar in _CUSTOM_GRAMMAR_LIST:
--> 129         if grammar[0].match(mail_exchanger):
    130             return grammar[1]
    131 

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

I found the fix
flanker/flanker/addresslib/address.py line 322

from
plugin = plugin_for_esp(exchanger)

to
plugin = plugin_for_esp(exchanger.decode('utf-8'))

@chingc
Copy link

chingc commented Sep 15, 2020

I'm having the same problem on Python 3.6. I'm surprised no one has commented on this ticket created back in June.

@guillaume-miara
Copy link

guillaume-miara commented Jun 8, 2021

Any updates on this issue? Anything preventing the review of the pull request?

@chingc
Copy link

chingc commented Jul 13, 2021

Any updates on this issue? Anything preventing the review of the pull request?

Feels like a dead project to me.

@tinducvo
Copy link

Hey guys!
This has actually been fixed, but the pypi package isn't up to date. Anyone know who we should contact?

https://github.com/mailgun/flanker/pull/245/files

@tinducvo
Copy link

skip_remote_checks = True is a workaround ... as long as you guys don't need more stringent validation for production. I'd like to have it, so I'm awaiting.

@TheDelta
Copy link

Python 3.9 and Flanker v0.9.14 and issue does still exist.
Idk why the PR was never merged in :(

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 a pull request may close this issue.

5 participants