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, gvanrossum
Date 2019-10-09.14:44:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1570632273.14.0.431057112609.issue38408@roundup.psfhosted.org>
In-reply-to
Content
Yes, that does work:

>>> urllib.parse.urlunparse(("http", f"{host}:{port}", "/", "", "", ""))
'http://hostname:1234/'



The only problem is that your code now needs to look like

>>> port=None
>>> urllib.parse.urlunparse(("http", f"{host}{(':' + str(port)) if port else ''}", "/", "", "", ""))
'http://hostname/'
History
Date User Action Args
2019-10-09 14:44:33eric.smithsetrecipients: + eric.smith, gvanrossum, Amir, James Allsopp
2019-10-09 14:44:33eric.smithsetmessageid: <1570632273.14.0.431057112609.issue38408@roundup.psfhosted.org>
2019-10-09 14:44:33eric.smithlinkissue38408 messages
2019-10-09 14:44:33eric.smithcreate