The attached patches update the standard library so that all modules
have docstrings beginning with one-line summaries.
A new docstring was added to formatter. The docstring for os.py
was updated to mention nt, os2, ce in addition to posix, dos, mac.
If a filename on Windows starts with \\, it is converted to a URL
which starts with ////. If this URL is passed to urlparse.urlparse
you get a path that starts with // (and an empty netloc). If you pass
the result back to urlparse.urlunparse, you get a URL that starts with
//, which is parsed differently by urlparse.urlparse. The fix is to
add the (empty) netloc with accompanying slashes if the path in
urlunparse starts with //. Do this for all schemes that use a netloc.
netloc from the base url as the default netloc for the resulting url
even if the schemes differ.
Once upon a time, when the web was wild, this was a valuable hack
because some people had a URL referencing an ftp server colocated with
an http server without having the host in the ftp URL (so they could
replicate it or change the hostname easily).
More recently, after the file: scheme got added back to the list of
schemes that accept a netloc, it turns out that this caused weirdness
when joining an http: URL with a file: URL -- the resulting file: URL
would always inherit the host from the http: URL because the file:
scheme supports a netloc but in practice never has one.
There are two reasons to get rid of the old, once-valuable hack,
instead of removing the file: scheme from the uses_netloc list. One,
the RFC says that file: uses the netloc syntax, and does not endorse
the old hack. Two, neither netscape 4.5 nor IE 4.0 support the old
hack.
1. use dict.get instead of try/except KeyError
2. if the url scheme is 'http' then avoid the series of
'if var in [someseq]:'. instead, inline all of the code.
3. find = string.find
default urlparse cache size to 20 instead of 2000. The main use of
the cache seems to be to gain some speed in Grail, which is calling
urljoin with the same base for each anchor. 2000 is a bit too big for
Jeremy, who doesn't need the cache at all. 20 should keep at least
95% of the Grail speedup while wasting an insignificant amount of
memory in Jeremy's application.