Showing content from http://mail.python.org/pipermail/python-dev/attachments/20120818/bc9b4690/attachment.html below:
<br><br>On Saturday, August 18, 2012, MRAB wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 18/08/2012 18:34, Guido van Rossum wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Sat, Aug 18, 2012 at 6:28 AM, Christian Heimes <<a>lists@cheimes.de</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Am 17.08.2012 21:27, schrieb Guido van Rossum:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I wonder if it wouldn't make sense to change urlencode() to generate<br>
URLs that don't depend on the hash order, for all versions of Python<br>
that support PYTHONHASHSEED? It seems a one-line fix:<br>
<br>
query = query.items()<br>
<br>
with this:<br>
<br>
query = sorted(query.items())<br>
<br>
This would not prevent breakage of unit tests, but it would make a<br>
much simpler fix possible: simply sort the parameters in the URL.<br>
</blockquote>
<br>
I vote -0. The issue can also be addressed with a small and simple<br>
helper function that wraps urlparse and compares the query parameter. Or<br>
you cann urlencode() with `sorted(qs.items)` instead of `qs` in the<br>
application.<br>
</blockquote>
<br>
Hm. That's actually a good point.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The order of query string parameter is actually important for some<br>
applications, for example Zope, colander+deform and other form<br>
frameworks use the parameter order to group parameters.<br>
<br>
Therefore I propose that the query string is only sorted when the query<br>
is exactly a dict and not some subclass or class that has an items() method.<br>
<br>
if type(query) is dict:<br>
query = sorted(query.items())<br>
else:<br>
query = query.items()<br>
</blockquote>
<br>
That's already in the bug I filed. :-) I also added that the sort may<br>
fail if the keys mix e.g. bytes and str (or int and str, for that<br>
matter).<br>
<br>
</blockquote>
One possible way around that is to add the class names, perhaps only if<br>
sorting raises an exception:<br>
<br>
def make_key(pair):<br>
return type(pair[0]).__name__, type(pair[1]).__name__, pair<br>
<br>
if type(query) is dict:<br>
try:<br>
query = sorted(query.items())<br>
except TypeError:<br>
query = sorted(query.items(), key=make_key)<br>
else:<br>
query = query.items()</blockquote><div><br></div><div>Doesn't strike me as necessary. <span></span></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
______________________________<u></u>_________________<br>
Python-Dev mailing list<br>
<a>Python-Dev@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/guido%40python.org" target="_blank">http://mail.python.org/<u></u>mailman/options/python-dev/<u></u>guido%40python.org</a><br>
</blockquote><br><br>-- <br>Sent from Gmail Mobile<br>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4