[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Python's urlparse.urljoin() (was: Re: Subversion portability)

From: Bruce Atherton <bruce_at_callenish.com>
Date: 2002-02-12 23:06:59 CET

At 12:35 PM 2/12/2002 -0800, Greg Stein wrote:
>If anybody can come up with a patch for urlparse.py, then I can check it
>into Python itself :-)

At first, I thought the problem was that the file scheme is in the list of
schemes that use the network host name part of a URL, but a file URL does
no such thing. Or does it? Can an NFS server or netware server to be
specified as file://nfs.mydomain.com/path/to/file.txt, for example?

Apparently it can:
     http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Lib/urlparse.py?rev=1.18&content-type=text/vnd.viewcvs-markup

So if this is correct, the real change belongs in urlunsplit(). I believe
this patch is correct:

Log:
* urlparse (urlunsplit): Correct test for prepending a "//" to a URL. This
fixes file URLs so that they unparse as "file:///path/to/file" rather than
"file:/path/to/file".

Index: urlparse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urlparse.py,v
retrieving revision 1.31
diff -u -r1.31 urlparse.py
--- urlparse.py 16 Nov 2001 02:52:57 -0000 1.31
+++ urlparse.py 12 Feb 2002 21:54:04 -0000
@@ -126,7 +126,7 @@
      return urlunsplit((scheme, netloc, url, query, fragment))

  def urlunsplit((scheme, netloc, url, query, fragment)):
- if netloc or (scheme in uses_netloc and url[:2] == '//'):
+ if netloc or (scheme in uses_netloc and url[:2] != '//'):
          if url and url[:1] != '/': url = '/' + url
          url = '//' + (netloc or '') + url
      if scheme:

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Sat Oct 21 14:37:07 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.