[Python-Dev] Should urlencode() sort the query parameters (if they come from a dict)?

Senthil Kumaran senthil at uthcode.com
Sun Aug 19 19:18:29 CEST 2012


On Sat, Aug 18, 2012 at 1:55 PM, Glenn Linderman <v+python at g.nevcal.com> wrote:
>
> On 8/18/2012 11:47 AM, MRAB wrote:
>
> I vote -0. The issue can also be addressed with a small and simple
> helper function that wraps urlparse and compares the query parameter. Or
> you cann urlencode() with `sorted(qs.items)` instead of `qs` in the
> application.
>
>
> Hm. That's actually a good point.
>
>
> Seems adequate to me. Most programs wouldn't care about the order, because most web frameworks grab whatever is there in whatever order, and present it to the web app in their own order.
>
> Programs that care, or which talk to web apps that care, are unlikely to want the order from a non-randomized dict, and so have already taken care of ordering issues, so undoing the randomization seems like a solution in search of a problem (other than for poorly written test cases).
>


I am of the same thought too. Changing a behavior based on the test
case expectation, no matter if the behavior is a harmless change is
still a change. Coming to the point testing query string could be
useful in some cases and then giving weightage to the change seems
interesting use case, but does not seem to warrant a change. I think,
I like Christian Heimes suggestion that a wrapper to compare query
strings would be useful and in Guido's original test case, a tittle
test code change would have been good.

Looks like Guido has withdrawn the bug report too.

-- 
Senthil


More information about the Python-Dev mailing list