[issue20059] Inconsistent urlparse/urllib.parse handling of invalid port values?

Martin Panter report at bugs.python.org
Wed Dec 17 05:03:48 CET 2014


Martin Panter added the comment:

I would go for raising ValueError for port numbers out of range. The value of None was already defined to mean that no port is included in the URL.

Also, the ValueError exception should be documented. It is surprising that urlsplit() does not raise any exception, but then simply getting the “port” attribute does raise the exception.

BTW your third example is wrong:

>>> urlparse("http://www.example.com:").port is None
True

It’s probably safest to keep this one as it is, but maybe it also needs documenting :)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20059>
_______________________________________


More information about the Python-bugs-list mailing list