This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ankitoshniwal
Recipients Buck.Golemon, ankitoshniwal
Date 2012-06-07.23:18:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1339111119.02.0.857676610651.issue15009@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-06-07 23:18:39ankitoshniwalsetrecipients: + ankitoshniwal, Buck.Golemon
2012-06-07 23:18:39ankitoshniwalsetmessageid: <1339111119.02.0.857676610651.issue15009@psf.upfronthosting.co.za>
2012-06-07 23:18:35ankitoshniwallinkissue15009 messages
2012-06-07 23:18:35ankitoshniwalcreate