Issue 972322: urllib2 handler naming convention collision (original) (raw)

Created on 2004-06-13 23:16 by jjlee, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
urllib2.py.patch jjlee,2004-06-13 23:16
test_urllib2.py.patch jjlee,2004-06-13 23:17
collision.patch jjlee,2006-03-31 21:16
collision_v2.patch jjlee,2006-05-27 23:58
Messages (7)
msg46172 - (view) Author: John J Lee (jjlee) Date: 2004-06-13 23:16
The method naming conventions of *_open and *_request in urllib2 are accidentally met by the following methods: AbstractHTTPHandler.do_open() ProxyHandler.proxy_open() AbstractHTTPHandler.redirect_request() So URLs like do://example.com/ are regarded as having a handler, and urllib2.urlopen("do://python.org/") causes a TypeError. I think *something* should be done about this, but I'm willing to provide a different patch if this one is frowned upon. The alternative would be to rename do_open and proxy_open, and leave the redirect_request case unchanged (see below for why). The first two methods are undocumented, so could in theory be renamed. However, people will likely be overriding them anyway, so perhaps it's better to apply this ugly patch than rename them. redirect_request is documented, so can't be renamed, but it will never be accidentally called unless somebody actually adds a handler with a method named "redirect_open".
msg46173 - (view) Author: Michael Chermside (mcherm) (Python triager) Date: 2004-10-22 16:36
Logged In: YES user_id=99874 I have reviewed this patch and I recomend applying it.
msg46174 - (view) Author: John J Lee (jjlee) Date: 2005-05-19 20:53
Logged In: YES user_id=261020 Since nobody seems to mind the slightly uglified code required to fix these bugs in a backwards-compatible way, could somebody please apply this patch?
msg46175 - (view) Author: John J Lee (jjlee) Date: 2006-03-31 21:16
Logged In: YES user_id=261020 Here's an updated patch (collision.patch) that applies against SVN HEAD. I also made the test a little clearer. collision.patch supercedes both urllib2.py.patch and test_urllib2.py.patch
msg46176 - (view) Author: John J Lee (jjlee) Date: 2006-05-07 22:27
Logged In: YES user_id=261020 OK, I see a slightly less ugly fix, don't apply this. I intend to upload a better one later.
msg46177 - (view) Author: John J Lee (jjlee) Date: 2006-05-27 23:58
Logged In: YES user_id=261020 OK, collision_v2.patch is less ugly, and supercedes all the previous patches attached to this tracker item.
msg46178 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-05-29 20:53
Logged In: YES user_id=849994 Applied in rev. 46531.
History
Date User Action Args
2022-04-11 14:56:04 admin set github: 40395
2004-06-13 23:16:17 jjlee create