Catch urlopen TypeError when context arg isn't supported.

Python changed the behavior and args for urllib.urlopen; the context
arg is needed to avoid cert checking in 3.4.3 and later, but isn't
supported before, where the default is to not check certs.
This commit is contained in:
John Ralls 2015-11-14 12:19:28 -08:00
parent 7b6832eea7
commit 388aef3a92

View File

@ -199,6 +199,10 @@ def available_updates():
URL = ("%s/listings/addons-%s.txt" %
(config.get("behavior.addons-url"), lang[:2]))
fp = urlopen(URL, timeout=10, context=context)
except TypeError:
URL = ("%s/listings/addons-%s.txt" %
(config.get("behavior.addons-url"), lang[:2]))
fp = urlopen(URL, timeout=10)
except Exception as err: # some error
LOG.warning("Failed to open addon metadata for {lang} {url}: {err}".
format(lang=lang, url=URL, err=err))