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 during email validation #218

Open
mithunmanohar opened this issue Nov 27, 2018 · 5 comments
Open

TypeError during email validation #218

mithunmanohar opened this issue Nov 27, 2018 · 5 comments

Comments

@mithunmanohar
Copy link

When I am trying to validate a email, getting the below error both in python 2 and 3.

address.validate_address('[email protected]')

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flanker\utils.py", line 64, in wrapper
    return_value = f(*args, **kwargs)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flanker\addresslib\address.py", line 312, in validate_address
    exchanger, mx_metrics = mail_exchanger_lookup(paddr.hostname, metrics=True)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flanker\utils.py", line 64, in wrapper
    return_value = f(*args, **kwargs)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flanker\addresslib\validate.py", line 156, in mail_exchanger_lookup
    mx_hosts = lookup_domain(domain)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flanker\addresslib\validate.py", line 210, in lookup_domain
    if len(mx_hosts) == 0:
TypeError: object of type 'filter' has no len()

Anyone faced similar issue ?

@amk5
Copy link

amk5 commented Dec 15, 2018

Try adding:

from functools import reduce

def ilen(iterable):
    return reduce(lambda sum, element: sum + 1, iterable, 0)

Then change the lookup_domain method in validate.py:

len_mx_hosts = ilen(_get_dns_lookup()[fqdn])
 if len_mx_hosts == 0:
  return None

@robbymurphy
Copy link

+1

Getting the same issue when trying to validate. The validate_address method seems like a pretty essential api method and it is completely broken.

from flanker.addresslib import address

print(address.validate_address('[email protected]'))
...
File "/Users/rmurphy/.pyenv/versions/3.6.0/lib/python3.6/site-packages/flanker/addresslib/validate.py", line 210, in lookup_domain
    if len(mx_hosts) == 0:
TypeError: object of type 'filter' has no len()

@jrborbars
Copy link

+1
Python (CPython 3.7.3), Flask 1.0.2, same line as above (@robbymurphy ).
TypeError: object of type 'filter' has no len()

if len(mx_hosts) == 0:

@dineshrav
Copy link

dineshrav commented Oct 18, 2019

I am having the exact same issue... Can anyone help.... I tried the option suggested by @amk5.. still no luck

@chingc
Copy link

chingc commented Jun 19, 2020

Updating to 0.9.11 fix this issue for me.

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

No branches or pull requests

6 participants