Comment #3 on issue 3339 by [email protected]: print PYTHONHASHSEED value when set as random
http://code.google.com/p/sympy/issues/detail?id=3339

OK, a few points:

…it would be nice to see the value that was chosen rather than the word "random" in the report:

PYTHONHASHSEED=… just prints the value of the environment variable. If it says "random" than that's just what it's set to. What command did you use that gave that output?

Also, perhaps the --no-subprocess should take priority over a value of PYTHONHASHSEED. If I set PYTHONHASHSEED then the --no-subprocess doesn't shut off hash randomization.

That's unfortunately not how it works. PYTHONHASHSEED is an environment variable. When it's set, Python enables hash randomization. There's no way to disable it, other than to clear the hash seed environment variable *before Python is started*.

But even if we did that, we would have to clear the environment variable and then start a new subprocess, which is exactly what --no-subprocess disables. So your suggestion is contradictory. I intentionally didn't add options to enable or disable hash randomization directly because it is controlled by environment variables, so if you want to change it you should just use those directly.

If you really want to disable hash randomization, you should set PYTHONHASHSEED to 0 (see http://docs.python.org/dev/using/cmdline.html#envvar-PYTHONHASHSEED).

I actually added --no-subprocess in case any system had problems spawning a new subprocess. The fact that it happens to disable hash randomization in Python < 3.3 is just an artifact of how it works.

Does that make sense?

And seed (not the PYTHONHASHSEED) uses 100000000; should it also use 2**32?

If I understand the docs correctly, it should use 2**n, where n is the architecture of the system. That's because random.seed just uses the hash of the input, and that's the range of hash(). See http://docs.python.org/library/random.html#random.seed. Actually, I guess that means it can just use 2**64 everywhere, and the hash will always "wrap" to the system allowed values.

When running just the doctests it would be very helpful to have the same info-header printed as when running tests. e.g. " bin\doctest examples.rst " just prints the failure but I don't know what PYTHONHASHSEED was used.

OK, that's a bug. The header should always be printed, even if only html doctests are being run.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to