flanker
flanker copied to clipboard
TypeError during email validation
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 ?
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
+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()
+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:
I am having the exact same issue... Can anyone help.... I tried the option suggested by @amk5.. still no luck
Updating to 0.9.11 fix this issue for me.