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 gvanrossum
Recipients gvanrossum
Date 2012-08-17.20:44:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1345236293.12.0.120802358061.issue15719@psf.upfronthosting.co.za>
In-reply-to
Content
From http://mail.python.org/pipermail/python-dev/2012-August/121364.html :

"""
I just fixed a unittest for some code used at Google that was
comparing a url generated by urllib.encode() to a fixed string. The
problem was caused by turning on PYTHONHASHSEED=1. Because of this,
the code under test would generate a textually different URL each time
the test was run, but the intention of the test was just to check that
all the query parameters were present and equal to the expected
values.

The solution was somewhat painful, I had to parse the url, split the
query parameters, and compare them to a known dict.

I wonder if it wouldn't make sense to change urlencode() to generate
URLs that don't depend on the hash order, for all versions of Python
that support PYTHONHASHSEED? It seems a one-line fix:

        query = query.items()

with this:

        query = sorted(query.items())

This would not prevent breakage of unit tests, but it would make a
much simpler fix possible: simply sort the parameters in the URL.
"""

MvL's response (http://mail.python.org/pipermail/python-dev/2012-August/121366.html) seems to suggest that this can go in as a bugfix in 3.2 and later if augmented with a check for type(query) is dict and a check for whether dict hashing is enabled.

Does anyone want to turn this idea into a patch?
History
Date User Action Args
2012-08-17 20:44:53gvanrossumsetrecipients: + gvanrossum
2012-08-17 20:44:53gvanrossumsetmessageid: <1345236293.12.0.120802358061.issue15719@psf.upfronthosting.co.za>
2012-08-17 20:44:52gvanrossumlinkissue15719 messages
2012-08-17 20:44:52gvanrossumcreate