Ankit Toshniwal <ankitoshni...@gmail.com> added the comment: Hello,
Did some initial investigation, so looks like as per the code in parse.py, under the function urlunsplit, we take the 5-tuple returned by urlsplit . In the case of foo we get: SplitResult(scheme='yelp', netloc='', path='/foo', query='', fragment='') Now this tuple is passed to urlunsplit. We have a if statement under the urlunsplit function if netloc or (scheme and scheme in uses_netloc and url[:2] != '//'): which checks if the netloc exists in the url (in our case it does not) then we check if the scheme in the url is part of the uses_netloc list (predefined list in parse.py with the list of common types of schemes used like http, ftp, file, rsync etc). In our case since yelp is not part of it we fail at the if statement and then we just return the url instead of modifying it. What we need was that if the above statement fails we do an else which does something like this: if netloc or (scheme and scheme in uses_netloc and url[:2] != '//'): if url and url[:1] != '/': url = '/' + url url = '//' + (netloc or '') + url else: if url and url[:1] != '/': url = '/' + url url = '//' + (netloc or '') + url In that case we get the right url back. After changing the code here is what i get on local dev machines: >>> urlunparse(urlparse('yelp:///foo')) 'yelp:///foo' >>> urlunsplit(urlsplit('file:///tmp')) 'file:///tmp' >>> urlunsplit(urlsplit('yelp:///foo')) 'yelp:///foo' Thanks, Ankit. P.S : I am new to python trying to learn it and also work on small projects let me know what you think if this is the right approach. ---------- nosy: +ankitoshniwal Added file: http://bugs.python.org/file25862/parse.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15009> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com