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: urllib2 doesn't handle urls without a scheme
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: fdrake, jackjansen
Priority: normal Keywords:

Created on 2005-01-07 12:49 by jackjansen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg23884 - (view) Author: Jack Jansen (jackjansen) * (Python committer) Date: 2005-01-07 12:49
Unlike urllib, urllib2 does not handle "/path/to/file" style urls 
(without a scheme) as "file:" urls.

I'm not sure whether this is a bug per se, but if this behaviour is 
by design then urllib2 should get a pathname2url() method that 
changes a pathname to a "file:"-prefixed url. urllib.pathname2url() 
does not prefix the url, but that's fine because urllib.urlopen() 
treats urls without schemes as file: urls.
msg23885 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2005-01-19 06:33
Logged In: YES 
user_id=3066

There's no such thing as a URL without a scheme, regardless
of what browsers do.  The best thing to do is to determine
the "base" to which a relative URL reference (whcih can have
the scheme omitted) should be resolved, and join the base
and relative URL reference using urlparse.urljoin(base, rel).

Closing as "not a bug".

urllib.pathname2url() is a problem in it's own right; it
doesn't behave consistently across Windows and Unix.  On
Windows, pathname2url() returns too many slashes, or it
returns too few on Unix.  I've been using helper functions
that hide that difference.
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41408
2005-01-07 12:49:35jackjansencreate