[BUG] http proxy overriding problem / env var problem on the other OS

K Thananchayan thananck at yahoo.com
Wed Aug 3 05:14:52 CDT 2005


Hi, 

--- Edouard Gomez <ed.gomez at free.fr> wrote:

> Seems like environment vars in the other OS are also
> case insensitive, and for
> the proxy env var handling, this raises an
> exception. Due to my python
> newbiness, i could not fix the bug.

While Win32 api functions
GetEnvironmentVariable/SetEnvironmentVariable
manipulate environment variables in case insensitive
and case preserving fashion (Python does not use these
functions), I do not think that this is the cause of
your problems.

> The symptoms, while trying to pull from http repos
> through proxy, i get this
> clueless error:
> $ hg pull http://www.selenic.com/hg
> pulling from http://www.selenic.com/hg
> abort: No such file or directory: None
> 
> $ hg version
> Mercurial version eef752151556
> 
> Copyright (C) 2005 Matt Mackall <mpm at selenic.com>
> This is free software; see the source for copying
> conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS
> FOR A PARTICULAR PURPOSE.
> 
> The erroneous code has been narrowed to:
> httprepository.__init__ at command.py
> # 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]
> It seems like this code tries to delete "HTTP_PROXY"
> though i'm using
> "http_proxy" lower case version. I found this by
> adding some nasty ui.warn
> calls in the if block.

This is just trying to remove "HTTP_PROXY",
"http_proxy", "no_proxy" entires from os.environ dict,
if such entries exist.

> 
> Trying this didn't help:
> for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]:
>     if os.environ.has_key(env):
>         try: del os.environ[env]
>         except KeyError: pass
> 
> So can somebody look at this, or provide me enough
> advise to try to fix this by
> myself ?

Can you please add the following after the last line 
       urllib2.install_opener(opener)
of httprepository.__init__ method having same
indentaton
 and let us know what is output by hg?

       print "Environment:", os.environ
       print "opener: ", urilib2._opener.handle_open
       print "proxy handler:", proxy_handler
       print "proxy_handler.http_open default args"
       print proxy_handler.http_open.func_defaults
 
> NB: the windows version of the proxy handler looks
> for IE registry keys
> concerning proxy definition (i looked at the python
> lib source code), there is
> a kind of conflict in the way hg tries to be smart
> about proxy handling, as the
> local hgrc value has never been used during my tests
> on win32. Given the
> presence of this special loop to allow overriding of
> the HTTP handler on
> Unix-like platforms, a similar workaround should be
> provided for win32 users
> desiring to override their registry keys, no ?

Although the code comments says that proxy specified
in the environment variables override the one
explicitly given to the proxy_handler, I am unable to
figure out how that is possible? 

> --
> Edouard Gomez

Thanks,

-thanan


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Mercurial mailing list