Problem using os.path.normpath on Windows

Matt Lavin matt.lavin at gmail.com
Fri Aug 19 04:54:41 BST 2005


I was testing out bzr on Windows and I ran into a small problem with 
fetching from an http url.  If I execute `bzr branch 
http://bazaar-ng.org/bzr/bzr.dev` then I get a failure in _make_request 
telling me that I received a HTTP 404 failure. 

I did a little debugging and found that the line 'path = 
os.path.normpath(path)' in bzrutil/urlgrabber/grabber.py ( is _parse_url 
) is the problem.  That method does not work like the method expects 
when running on windows since the forward slashes get translated to 
backwards slashes. 

Adding some prints before and after the normpath call show that the path 
goes from
    /bzr/bzr.dev/.bzr/branch-format
to
    \bzr\bzr.dev\.bzr\branch-format
and because of the new backwards slashes the next line (which calls 
urllib.quote ) changes the path to
    %5Cbzr%5Cbzr.dev%5C.bzr%5Cbranch-format
and naturally that results in the 404. 

I'm not well versed in the python libraries and my solution would be to 
implement something like normpath that leaves forward slashes as forward 
slashes, called maybe normurl(), but I thought I'd post to the list for 
input.




More information about the bazaar mailing list