This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Custom handlers not used when passing "context" argument to urllib2.urlopen()
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: urllib.parse.urlopen shouldn't ignore installed opener when called with any SSL argument
View: 18543
Assigned To: Nosy List: martin.panter, piotr.dobrogost
Priority: normal Keywords:

Created on 2017-01-26 17:09 by piotr.dobrogost, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg286325 - (view) Author: Piotr Dobrogost (piotr.dobrogost) Date: 2017-01-26 17:09
When urllib2.urlopen() is passed "context" argument the new opener is being built (https://hg.python.org/cpython/file/a06454b1afa1/Lib/urllib2.py#l147) and used instead custom opener which might had been already installed with urllib2.install_opener(). This might lead to problems with proxies if custom ProxyHandler was used in custom opener – see http://stackoverflow.com/q/36089694/95735 as an example.
msg286340 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017-01-27 00:21
I presume this is the same as in Issue 18543 (and a few other duplicates). Let me know if I got it wrong.

IMO there is no easy fix. The best solution may be to just document the behaviour as a limitation of the API, and design a new/improved API for the future (Py 3.7+) that handles these cases.
History
Date User Action Args
2022-04-11 14:58:42adminsetgithub: 73565
2017-01-27 00:21:38martin.pantersetstatus: open -> closed

nosy: + martin.panter
messages: + msg286340

superseder: urllib.parse.urlopen shouldn't ignore installed opener when called with any SSL argument
resolution: duplicate
2017-01-26 17:09:46piotr.dobrogostcreate