[issue18857] urlencode of a None value uses the string 'None'
Joshua Johnston
report at bugs.python.org
Fri Feb 7 20:21:06 CET 2014
Joshua Johnston added the comment:
If this was a function to encode a dict into something then I would see your point and agree. urlencode is specifically designed to work within the domain or URIs. In this domain, it is acceptable to have an empty value for a key in a query string. None is a representation of nothing, empty, null, the absence of a value. Therefore you would expect a function in the domain of URIs to construct a valid URI component when you specifically tell it to use None. Valid is up to you, either ignore the key-value pair completely, or use key[=&] to represent the empty value.
Take Requests as an example that gets it right:
>>> import requests
>>> requests.get('http://www.google.com/', params={'key': None}).url
u'http://www.google.com/'
>>> requests.get('http://www.google.com/', params={'key': ''}).url
u'http://www.google.com/?key='
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18857>
_______________________________________
More information about the Python-bugs-list
mailing list