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 orsenthil
Recipients William.Wu, georg.brandl, orsenthil, vstinner
Date 2011-02-10.15:23:39
SpamBayes Score 7.333023e-14
Marked as misclassified No
Message-id <AANLkTinPjjO9WpoQmkrSfRbXheZLt5fGsuyXiy_5SLOb@mail.gmail.com>
In-reply-to <1296837184.1.0.588454218465.issue11082@psf.upfronthosting.co.za>
Content
On Sat, Feb 5, 2011 at 12:33 AM, Georg Brandl <report@bugs.python.org> wrote:
>
> Then let us do that.
>
> Senthil, what about urlencode of bytes values returning a str?
>

Sorry, the late response. I needed some time to look at this one and I
could only do it today.
We have been having str return value from urlencode, due to quote,
quote_plus methods which can take bytes/str but return str. (urlencode
is nothing but quote_plus which acts on two-element sequences like
name,value pairs.

The resultant str is certainly useful when we want to construct a URL
query string. But, when we want to do a POST via urlopen, we need
bytes data. So, I think best to advice through the documentation that,
urlencoded value must be converted to bytes if it is to be used for
POST'ing using urlopen.

(Well, I also think that urllencode could be modified to the effect
that if the key,value pairs are bytes, return the bytes output.
Technically, this would involve overriding some behavior of
quote/quote_plus and the return value will suitable only for POST data
and not for url query construction. I would rather choose to discuss
this before settling on the behavior and I remember that quote's
behavior did take a significant amount discussion).

So, for this issue. A patch would a prevent str data from being posted
with ValueError explaining the reason that bytes and required and a
documentation update in the urlencode method which would inform the
users that the output be converted to bytes before it is POSTed,

Shall we go ahead with this, Georg?  I shall post a patch immediately.
History
Date User Action Args
2011-02-10 15:23:41orsenthilsetrecipients: + orsenthil, georg.brandl, vstinner, William.Wu
2011-02-10 15:23:39orsenthillinkissue11082 messages
2011-02-10 15:23:39orsenthilcreate