From e2a36dda0a4bd0b09d76fe6bf30e6fca4d2822ca Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Tue, 7 Jan 2014 09:37:59 +0000 Subject: [PATCH] Don't let proxy_bypass bring you down. --- requests/utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/requests/utils.py b/requests/utils.py index c7e2b089..e69e9a81 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -487,7 +487,16 @@ def get_environ_proxies(url): # If the system proxy settings indicate that this URL should be bypassed, # don't proxy. - if proxy_bypass(netloc): + # The proxy_bypass function is incredibly buggy on OS X in early versions + # of Python 2.6, so allow this call to fail. Only catch the specific + # exceptions we've seen, though: this call failing in other ways can reveal + # legitimate problems. + try: + bypass = proxy_bypass(netloc) + except (TypeError, socket.gaierror): + bypass = False + + if bypass: return {} # If we get here, we either didn't have no_proxy set or we're not going