Index: Doc/library/urllib.request.rst =================================================================== --- Doc/library/urllib.request.rst (revision 86560) +++ Doc/library/urllib.request.rst (working copy) @@ -367,7 +367,15 @@ To disable autodetected proxy pass an empty dictionary. + .. note:: + The proxy environment variable name is not case sensitive. ProxyHandler + will prefer an all lower case name, such as http_proxy, over any of the + others if it exists. HTTP_PROXY or HTTP_proxy will be accepted if + http_proxy is not defined. If both HTTP_PROXY and HTTP_proxy exist, which + one will be preferred is not well defined. + + .. class:: HTTPPasswordMgr() Keep a database of ``(realm, uri) -> (user, password)`` mappings. Index: Lib/urllib/request.py =================================================================== --- Lib/urllib/request.py (revision 86560) +++ Lib/urllib/request.py (working copy) @@ -2172,9 +2172,15 @@ """ proxies = {} for name, value in os.environ.items(): - name = name.lower() - if value and name[-6:] == '_proxy': - proxies[name[:-6]] = value + lname = name.lower() + # We prefer the all lower case version of the variable if it + # exists, but we will accept something of any case if there + # isn't anything better + if value and lname[-6:] == '_proxy': + if name == lname: + proxies[lname[:-6]] = value + elif lname[:-6] not in proxies: + proxies[lname[:-6]] = value return proxies def proxy_bypass_environment(host):