[Python-porting] Control of hash randomization

Aaron Meurer asmeurer at gmail.com
Sun May 27 06:58:13 CEST 2012


Hi.

First, I want to apologize if this is the wrong list for this
question. If it is, kindly direct me to the correct one and I'll be on
my way.

I am attempting to "port" SymPy to Python 3.3.  We already have full
support for Python 3.2, but the new hash randomization in Python 3.3
has brought up a bunch of new failures in our test suite.  This is not
a surprise, as a lot of operations in SymPy are dependent on hash
values.  But expecting the problem does not entirely help use to solve
it.

My question is this: is there a way to get the random seed used for
hash randomization, and to print it out, and then to later input that
seed to the interpreter?  Without this ability, it becomes extremely
difficult to reproduce test failures.  The best bet is to restart the
interpreter multiple times until it occurs.  We already have
experienced in SymPy several odd bugs that were caused by very rare
seeds in the random module.  This seed is easy to set, though, and we
print it with each test run, so the handful of issues that have
cropped up we've been able to fix.  I'd like to have that same ability
with hash randomization.

I figured that this is a new feature, and people on this list are
supposed to be experts on new Python features, so my hope is that
either someone here will know the answer, or can point me in the right
direction to one.

If it is the case, as I fear/expect, that this is not possible, should
I open an issue in the Python bug tracker?  Should I raise the issue
on python-dev?  Has it been discussed before?  I realize that there
may be a security risk (imho a low one, though) in such a feature, so
it might not be immediately accepted.

Aaron Meurer


More information about the Python-porting mailing list