[Python-Dev] urllib2/urllib incompatibility? (original) (raw)

Senthil Kumaran orsenthil at gmail.com
Mon May 24 11:37:16 CEST 2010


On Mon, May 24, 2010 at 08:49:56AM +0000, Vinay Sajip wrote:

I encountered what seems like an incompatibility between urllib and urllib2 in the way they handle file:// URLs, is this a bug? I had a look on the bug tracker

>>> s = 'file:////tmp/hello.txt' >>> f1 = urllib.urlopen(s)

The actual (and Valid) file:// url in your case is 'file:///tmp/hello.txt' And this was fine and consistent.

s = 'file:///tmp/hello.txt' import urllib2 import urllib o1 = urllib.urlopen(s) o2 = urllib2.urlopen(s)

The extra '/' is making it in invalid url in urllib2, I think that be tracked as bug at least to show a consistent behaviour. The local file open methods of urllib2 and urllib are different.

-- Senthil

You may my glories and my state dispose, But not my griefs; still am I king of those. -- William Shakespeare, "Richard II"



More information about the Python-Dev mailing list