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

Berker Peksag report at bugs.python.org
Tue Mar 20 09:00:01 EDT 2018


Berker Peksag <berker.peksag at gmail.com> added the comment:

The problem with adding a port_validation argument is that the port attribute is not the only thing that is computed lazily. There is also hostname, username, password attributes etc.

I think the best way would be introducing a new API with more strict parsing rules. For example:

    from urllib.parse URL

    url = URL('http://Server=sde; Service=sde:oracle').parse()

would raise a ValueError earlier than urlparse() and return a immutable namedtuple.

Such an API can be designed as a standalone module first and then can be added into the existing urllib.parse module. I'd personally happy to review and discuss such a modern and user friendly API in the standard library.

I think Eric has explained the current situation perfectly and we can now close this issue. We can create a new issue or a new python-ideas thread when or if we have a prototype of a new API.

Thank you, everyone!

----------
components: +Library (Lib)
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> enhancement
versions: +Python 3.8 -Python 2.7, Python 3.5, Python 3.6

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


More information about the Python-bugs-list mailing list