Author Stephen.Day
Recipients Stephen.Day
Date 2012-01-25.22:12:01
SpamBayes Score 2.63085e-11
Marked as misclassified No
Message-id <1327529522.13.0.464287316871.issue13866@psf.upfronthosting.co.za>
In-reply-to
Content
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'
History
Date User Action Args
2012-01-25 22:12:02Stephen.Daysetrecipients: + Stephen.Day
2012-01-25 22:12:02Stephen.Daysetmessageid: <1327529522.13.0.464287316871.issue13866@psf.upfronthosting.co.za>
2012-01-25 22:12:01Stephen.Daylinkissue13866 messages
2012-01-25 22:12:01Stephen.Daycreate