mailgun/flanker — pull request #31 by dmpayton (2014-02-14 00:14:51+00:00)
Title: Account for a cached value of False when validating.

Hi there,

I had an issue on django-flanker that I've traced to flanker itself.

https://github.com/dmpayton/django-flanker/issues/2

If `connect_to_mail_exchanger` throws an exception or fails to connect for whatever, it returns None and `mail_exchanger_lookup` will set `mx_cache[domain]` to False.

This is not accounted for on subsequent calls to `validate_address`. If the cached value is None, it returns None, otherwise it continues. If the cached value is False, it throws the following exception:

```
Traceback (most recent call last):
File "", line 1, in
File "/home/derek/dev/django-flanker/flanker/utils.py", line 99, in wrapper
return_value = f(*args, **kwargs)
File "/home/derek/dev/django-flanker/flanker/addresslib/address.py", line 205, in validate_address
plugin = flanker.addresslib.validate.plugin_for_esp(exchanger)
File "/home/derek/dev/django-flanker/flanker/addresslib/validate.py", line 108, in plugin_for_esp
if grammar[0].match(mail_exchanger):
TypeError: expected string or buffer
```

This patch simply returns None if the cached value is False.