[issue22234] urllib.parse.urlparse accepts any falsy value as an url

Antti Haapala report at bugs.python.org
Thu Apr 28 07:02:54 EDT 2016


Antti Haapala added the comment:

I do not believe there is code that would depend on `urlparse(urlstring={})` *not* throwing an error, since `{}` obviously is neither a URL, nor a string.

Further down the documentation explicitly states that

> The URL parsing functions were originally designed to operate on 
> character strings only. In practice, it is useful to be able to 
> manipulate properly quoted and encoded URLs as sequences of ASCII 
> bytes. Accordingly, the URL parsing functions in this module all 
> operate on bytes and bytearray objects in addition to str objects.

As the documentation does not state that it should work on any other objects, there shouldn't be any code that should be deprecated. Furthermore even in 3.5, the `bool(datetime.time(0, 0)) == False` was removed without any deprecation cycle, despite it having been a documented feature for more than a decade (unlike this one).

And IMHO not giving an object of expected type should result in a TypeError.

----------

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


More information about the Python-bugs-list mailing list