[issue33034] urllib.parse.urlparse and urlsplit not raising ValueError for bad port

Matt Eaton report at bugs.python.org
Thu Mar 15 21:56:05 EDT 2018


Matt Eaton <agnosticdev at gmail.com> added the comment:

"Wouldn't we be better off to catch this error at parse time, instead of just improve the error message when .port is called?"

I think there could be a case to be made about catching and dealing with this error in urlparse() / urlsplit() instead of displaying an error when port property is used.  I think that approaching it this way would cut right to the problem and alleviate carrying around a potentially bad port value.  However, if the port error was caught during parsing but the url, scheme, etc.. values were still valid, are we taking away something from the user by raising the error too soon?  Just a thought.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33034>
_______________________________________


More information about the Python-bugs-list mailing list