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 eric.smith
Recipients Amir, James Allsopp, eric.smith
Date 2019-10-08.12:34:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1570538078.47.0.890268307934.issue38408@roundup.psfhosted.org>
In-reply-to
Content
One way I can think of doing this in a backward compatible way is to add keyword parameters to urlunparse, like:

def urlunparse(components, *, username=None, password=None, hostname=None, port=None):

Which would make your call:
site_to_test = urllib.parse.urlunparse((scheme, host, page, '', '', ''), port=9097)

I think that's a horrible interface, but it is backward compatible.

A better interface would be have all 10 URL parameters passed in as keyword arguments, with reasonable defaults. If you want to keep this named "urlunparse", you'd need to say you can't pass in both "components" and any other named parameter (other than maybe the 4  parameters that are unnamed in ParseResult).

Something like:
def urlunparse(components=None, scheme=None, netloc=None, path=None, params=None, query=None, fragment=None, *, username=None, password=None, hostname=None, port=None):

Then error if components is set and any of scheme, netloc, path, params, query, or fragment is also set.

We could bikeshed about which would be keyword-only, if any, all, or only some as I've shown here.

Another option would be to leave urlunparse alone, and add a new function entirely, which wouldn't have to worry about backward compatibility.

It might be worthwhile to raise this on python-ideas.
History
Date User Action Args
2019-10-08 12:34:38eric.smithsetrecipients: + eric.smith, Amir, James Allsopp
2019-10-08 12:34:38eric.smithsetmessageid: <1570538078.47.0.890268307934.issue38408@roundup.psfhosted.org>
2019-10-08 12:34:38eric.smithlinkissue38408 messages
2019-10-08 12:34:38eric.smithcreate