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

Martin Panter report at bugs.python.org
Mon Mar 23 05:57:00 CET 2015


Martin Panter added the comment:

Patch v2 just changes a test to use “with self.assertRaises()”.

The behaviour of urlparse() succeeding and then result.port failing is indeed odd and surprising. Hopefully documenting this behaviour will help with the “surprising” aspect. But changing it would surely break compatibility. For example, the following is still potentially useful:

>>> urlsplit("http://localhost:ipp/").netloc
'localhost:ipp'

On Unix, some programs look up port names in /etc/services, even though this is not valid for URLs according to the RFCs, and urlsplit().port does not support it. In this case “ipp” would be whatever port the Internet Printing Protocol server is configured to run on.

----------
Added file: http://bugs.python.org/file38642/port-ValueError.v2.patch

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


More information about the Python-bugs-list mailing list