Trap OSError when deleting env vars
authorEdouard Gomez <ed.gomez@free.fr>
Tue, 09 Aug 2005 09:36:34 -0800
changeset 859 6390c377a9e6
parent 858 c333dfa8fa1a
child 866 6d6095823b82
child 871 c2e77581bc84
child 872 9a0af739cf55
child 881 16ce690c411d
Trap OSError when deleting env vars On the other OS, it seems that case insensitivity for environment vars can bite users when using some unknown combination of python 2.4.1 and win2kSP4+minsys (and probably other vversions of these softwares). The best way to avoid problems in those weird cases is to ignore OSError exception during env var deletion.
mercurial/hg.py
--- a/mercurial/hg.py	Mon Aug 08 19:49:48 2005 -0800
+++ b/mercurial/hg.py	Tue Aug 09 09:36:34 2005 -0800
@@ -1781,8 +1781,11 @@
         # 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: