This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Joshua.Johnston
Recipients Claudiu.Popa, Joshua.Johnston, ezio.melotti, orsenthil, r.david.murray
Date 2014-02-07.19:21:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1391800866.67.0.940792746064.issue18857@psf.upfronthosting.co.za>
In-reply-to
Content
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='
History
Date User Action Args
2014-02-07 19:21:06Joshua.Johnstonsetrecipients: + Joshua.Johnston, orsenthil, ezio.melotti, r.david.murray, Claudiu.Popa
2014-02-07 19:21:06Joshua.Johnstonsetmessageid: <1391800866.67.0.940792746064.issue18857@psf.upfronthosting.co.za>
2014-02-07 19:21:06Joshua.Johnstonlinkissue18857 messages
2014-02-07 19:21:06Joshua.Johnstoncreate