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 martin.panter
Recipients demian.brecht, martin.panter, orsenthil, soilandreyes
Date 2015-03-13.00:40:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1426207260.37.0.867917360519.issue22852@psf.upfronthosting.co.za>
In-reply-to
Content
There have been a few recent bug reports (Issue 23505, Issue 23636) that may be solved by the has_netloc proposal. So I am posting a patch implementing it. The changes were a bit more involved than I anticipated, but should still be usable.

I reused some of Stian’s tests, however the results are slightly different in my patch, matching the existing behaviour:

* Never sets netloc, query, fragment to None
* Always leaves hostname as None rather than ""
* Retains username, password and port components in netloc
* Converts hostname to lowercase

Unfortunately I discovered that you cannot add __slots__ to namedtuple() subclasses; see Issue 17295 and Issue 1173475. Therefore in my patch I have removed __slots__ from the SplitResult etc classes, so that those classes can gain the has_netloc etc attributes.

I chose to make the default has_netloc value based on existing urlunsplit() behaviour:

>>> empty_netloc = ""
>>> SplitResult("mailto", empty_netloc, "chris@example.com", "", "").has_netloc
False
>>> SplitResult("file", empty_netloc, "/path", "", "").has_netloc
True

I found out that the “urllib.robotparser” module uses a urlunparse(urlparse()) combination to normalize URLs, so had to be changed. This is a backwards incompatibility of this proposal.
History
Date User Action Args
2015-03-13 00:41:01martin.pantersetrecipients: + martin.panter, orsenthil, demian.brecht, soilandreyes
2015-03-13 00:41:00martin.pantersetmessageid: <1426207260.37.0.867917360519.issue22852@psf.upfronthosting.co.za>
2015-03-13 00:41:00martin.panterlinkissue22852 messages
2015-03-13 00:41:00martin.pantercreate