Skip to content

Commit 7316940

Browse files
committed
Fixed inability to run without http_proxy variable
The inability to run without the http_proxy or http_proxy variables is fixed. In an eariler commit, support for these were added, which caused issues in system where they were not set. This problem has been fixed.
1 parent 7715c16 commit 7316940

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

twitter.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3903,12 +3903,21 @@ def _FetchUrl(self,
39033903

39043904
http_handler = self._urllib.HTTPHandler(debuglevel=_debug)
39053905
https_handler = self._urllib.HTTPSHandler(debuglevel=_debug)
3906-
proxy_handler = self._urllib.ProxyHandler({'http': str(os.environ['http_proxy']), 'https': str(os.environ['http_proxy']) })
3906+
http_proxy = os.environ.get('http_proxy')
3907+
https_proxy = os.environ.get('https_proxy')
3908+
3909+
if http_proxy is None or https_proxy is None :
3910+
proxy_status = False
3911+
else :
3912+
proxy_status = True
39073913

39083914
opener = self._urllib.OpenerDirector()
39093915
opener.add_handler(http_handler)
39103916
opener.add_handler(https_handler)
3911-
opener.add_handler(proxy_handler)
3917+
3918+
if proxy_status is True :
3919+
proxy_handler = self._urllib.ProxyHandler({'http':str(http_proxy),'https': str(https_proxy)})
3920+
opener.add_handler(proxy_handler)
39123921

39133922
if use_gzip_compression is None:
39143923
use_gzip = self._use_gzip

0 commit comments

Comments
 (0)