[PATCH] Trap OSError when deleting env vars

Edouard Gomez ed.gomez at free.fr
Tue Aug 9 10:46:39 CDT 2005

# HG changeset patch
# User Edouard Gomez <ed.gomez at free.fr>
# Node ID b65f0b6ed4205a9c936c9fb66762d351e5bf6e8a
# Parent  c333dfa8fa1ab7fafdd99e4989a77b198fb04b59
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.

diff -r c333dfa8fa1a -r b65f0b6ed420 mercurial/hg.py
--- a/mercurial/hg.py	Tue Aug  9 03:49:48 2005
+++ b/mercurial/hg.py	Tue Aug  9 15:41:42 2005
@@ -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:

Edouard Gomez

More information about the Mercurial mailing list