mercurial/hg.py
changeset 859 6390c377a9e6
parent 856 fbe964ae7325
child 866 6d6095823b82
child 871 c2e77581bc84
child 872 9a0af739cf55
child 882 bc9ca4d51d23
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -1781,8 +1781,11 @@ class httprepository:
         # Note: urllib2 takes proxy values from the environment and those will
         # take precedence
         for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]:
-            if os.environ.has_key(env):
-                del os.environ[env]
+            try:
+                if os.environ.has_key(env):
+                    del os.environ[env]
+            except OSError:
+                pass
 
         proxy_handler = urllib2.BaseHandler()
         if host and not no_proxy: