You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Bruce Atherton <br...@callenish.com> on 2002/02/12 20:16:57 UTC
Re: Subversion portability
At 06:44 PM 2/11/2002 +0000, Philip Martin wrote:
>Ben Collins-Sussman <su...@collab.net> writes:
>
> > Branko Äibej <br...@xbc.nu> writes:
> >
> > > os.path.join() on windows never gives you a valid URL. *bonk*!
> >
>
>Greg Stein suggested urlparse.urljoin
>
>http://subversion.tigris.org/servlets/ReadMsg?msgId=53677&listName=dev
>
>but it didn't work for me
>
>http://subversion.tigris.org/servlets/ReadMsg?msgId=53693&listName=dev
>
>since file:///xxx gets converted to file:/xxx
Same for me on Windows using Activestate Python 2.1.1.
This should be easy to work around, though, if in a grotesque way:
# FIXME: On at least some versions of Python, a bug in urlparse.urljoin()
# strips required slashes out of a "file:" URL. This repairs the damage.
# Once Python is fixed to get it right, the required Python version
# should be upped and this code should be stripped.
import re
find_bad_url = re.compile("file:/[^/]")
if (find_bad_url.match(urlstring)) is not None:
urlstring = urlstring[0:5] + "//" + urlstring[5:]
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Python's urlparse.urljoin() (was: Re: Subversion
portability)
Posted by Bruce Atherton <br...@callenish.com>.
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:
file:/// URLs using Python's urlparse.urljoin() (was
Subversion portability)
Posted by Bruce Atherton <br...@callenish.com>.
At 02:29 PM 8/5/2002 -0500, Karl Fogel wrote:
>Is your workaround below still applicable, or did we solve this some
>other way? I didn't see anything in the logs indicating that this had
>been applied, nor that the problem had been addressed...
This wasn't a patch to a specific file, it was a hack to add whenever
someone wanted to use the Python urlparse.urljoin() method and still keep
the proper file:/// format. Grepping through the Subversion codebase now I
don't see urljoin() being used anywhere, probably at least in part because
of the slash-stripping bug.
I guess the hack is still applicable for anyone that wants to write a
python test that uses urlparse.urljoin() with file:/// URLs in a portable
way. I don't think there is anything specific that needs to be done about
it, though. I've changed the subject to make it easier to find in case
anyone needs it.
Thanks for reminding me about this. It prompted me to send in the patch to
fix the underlying Python bug.
[hack follows]
> # FIXME: On at least some versions of Python, a bug in urlparse.urljoin()
> # strips required slashes out of a "file:" URL. This repairs the damage.
> # Once Python is fixed to get it right, the required Python version
> # should be upped and this code should be stripped.
> import re
>
> find_bad_url = re.compile("file:/[^/]")
> if (find_bad_url.match(urlstring)) is not None:
> urlstring = urlstring[0:5] + "//" + urlstring[5:]
Re: Subversion portability
Posted by Karl Fogel <kf...@newton.ch.collab.net>.
Bruce, I'm reviewing some pending patches -- some of the older ones
may be obsolete by now, either because already applied, or because
some other fix did the job.
Is your workaround below still applicable, or did we solve this some
other way? I didn't see anything in the logs indicating that this had
been applied, nor that the problem had been addressed...
-Karl
Bruce Atherton <br...@callenish.com> writes:
> >Greg Stein suggested urlparse.urljoin
> >
> >http://subversion.tigris.org/servlets/ReadMsg?msgId=53677&listName=dev
> >
> >but it didn't work for me
> >
> >http://subversion.tigris.org/servlets/ReadMsg?msgId=53693&listName=dev
> >
> >since file:///xxx gets converted to file:/xxx
>
> Same for me on Windows using Activestate Python 2.1.1.
>
> This should be easy to work around, though, if in a grotesque way:
>
> # FIXME: On at least some versions of Python, a bug in urlparse.urljoin()
> # strips required slashes out of a "file:" URL. This repairs the damage.
> # Once Python is fixed to get it right, the required Python version
> # should be upped and this code should be stripped.
> import re
>
> find_bad_url = re.compile("file:/[^/]")
> if (find_bad_url.match(urlstring)) is not None:
> urlstring = urlstring[0:5] + "//" + urlstring[5:]
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Python's urlparse.urljoin() (was: Re: Subversion portability)
Posted by Greg Stein <gs...@lyra.org>.
If anybody can come up with a patch for urlparse.py, then I can check it
into Python itself :-)
(of course, given that Python 2.2 was just released, I don't expect 2.3 to
come out for a long while...)
Cheers,
-g
On Tue, Feb 12, 2002 at 12:16:57PM -0800, Bruce Atherton wrote:
> At 06:44 PM 2/11/2002 +0000, Philip Martin wrote:
>...
> >Greg Stein suggested urlparse.urljoin
> >
> >http://subversion.tigris.org/servlets/ReadMsg?msgId=53677&listName=dev
> >
> >but it didn't work for me
> >
> >http://subversion.tigris.org/servlets/ReadMsg?msgId=53693&listName=dev
> >
> >since file:///xxx gets converted to file:/xxx
>
> Same for me on Windows using Activestate Python 2.1.1.
>
> This should be easy to work around, though, if in a grotesque way:
>
> # FIXME: On at least some versions of Python, a bug in urlparse.urljoin()
> # strips required slashes out of a "file:" URL. This repairs the damage.
> # Once Python is fixed to get it right, the required Python version
> # should be upped and this code should be stripped.
> import re
>
> find_bad_url = re.compile("file:/[^/]")
> if (find_bad_url.match(urlstring)) is not None:
> urlstring = urlstring[0:5] + "//" + urlstring[5:]
--
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org