Jessica McKellar added the comment:

I confirm Barry's observation in msg94150 that if you set http_proxy (or any 
`*_proxy` environment variable), ProxyHandler does show up in 
build_opener().handlers. You can also add a ProxyHandler to build_opener 
through the public API as described in 
http://docs.python.org/dev/library/urllib.request.html#examples.

I've attached a patch that updates the urllib2 and urllib.request documentation 
to clarify the situation. The patch also adds a missing DataHandler to the 
enumerated default handlers in the urllib2 note on basic authentication.

I built the documentation and inspected the generated HTML to confirm proper 
formatting.

--

As a side note on what's going on with ProxyHandler's interaction with `if meth 
in ["redirect_request", "do_open", "proxy_open"]:`, since this was confusing to 
me until I dug into the source a bit:

When you don't have any proxy environment variables set, ProxyHandler only has 
one <protocol>_<condition> method that might get the handler registered -- 
proxy_open -- which gets skipped because of the above blacklisted methods 
check. When a proxy environment variable is set, ProxyHandler grows a *_open 
method which does get it registered as a handler.

----------
keywords: +patch
nosy: +jesstess
versions: +Python 3.3, Python 3.4 -Python 2.6
Added file: http://bugs.python.org/file29817/issue7152.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7152>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to