New submission from Stephen Day <[email protected]>:
The current behavior of the urlencode function (2.7: urllib, 3.x: urllib.parse)
encodes spaces as pluses:
>>> from urllib import urlencode
>>> urlencode({'a': 'some param'})
'a=some+param'
However, in most instances, it would be desirable to merely encode spaces using
percent encoding:
>>> urlencode({'a': 'some param'})
'a=some%20param'
But there is no way to get this behavior in the standard library.
It would probably best to change this so it defaults to use the regular quote
function, but allows callers who need the legacy quote_plus behavior to pass
that in as a function parameter.
An acceptable fix would be to have the quote function taken as a keyword
parameter, so legacy behavior remains:
>>> urlencode({'a': 'some param'})
'a=some+param'
Then the behavior could be adjusted where needed:
>>> from urllib import quote
>>> urlencode({'a': 'some param'}, quote=quote)
'a=some%20param'
----------
components: Library (Lib)
messages: 151980
nosy: Stephen.Day
priority: normal
severity: normal
status: open
title: {urllib,urllib.parse}.urlencode should not use quote_plus
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13866>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com