[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-31 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- resolution: -> fixed status: open -> closed ___ Python tracker ___

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-31 Thread Roundup Robot
Roundup Robot added the comment: New changeset 5ae941fef3be by Raymond Hettinger in branch '3.5': Issue #27706: Fix regression in random.seed(somestr, version=1) https://hg.python.org/cpython/rev/5ae941fef3be -- ___ Python tracker

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-31 Thread Roundup Robot
Roundup Robot added the comment: New changeset 1f37903e6040 by Raymond Hettinger in branch '2.7': Issue #27706: Document that random.seed() is non-deterministic when PYTHONHASHSEED is enabled https://hg.python.org/cpython/rev/1f37903e6040 -- nosy: +python-dev

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-31 Thread Nofar Schnider
Nofar Schnider added the comment: fixed indentation -- versions: -Python 2.7 Added file: http://bugs.python.org/file44309/issue27706.patch ___ Python tracker

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-31 Thread Raymond Hettinger
Raymond Hettinger added the comment: For 2.7, we're going to add a note to the docs. For 3.5 and 3.6, we're adjusting the version==1 logic to meet the documented guarantee. -- versions: +Python 2.7, Python 3.6 ___ Python tracker

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-31 Thread STINNER Victor
STINNER Victor added the comment: Nofar Schnider: "versions: + Python 3.5, - Python 2.7" I don't get it. This issue is specific to Python 2.7, no? > issue27706.patch If you want to backport this feature from Python 3, I suggest to reuse the same code (so SHA 512). You might get the same

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-31 Thread Nofar Schnider
Nofar Schnider added the comment: Adding the patch with seed fix for version=1 and tests (test_random). -- components: +Tests keywords: +patch versions: +Python 3.5 -Python 2.7 Added file: http://bugs.python.org/file44308/issue27706.patch ___ Python

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-17 Thread Glyph Lefkowitz
Glyph Lefkowitz added the comment: For what it's worth, I don't much care whether this is fixed or not; I ended up wanting to leak less information from the RNG output anyway so I wrote this: https://gist.github.com/glyph/ceca96100a3049fefea6f2035abbd9ea but I felt like it should be reported.

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-17 Thread STINNER Victor
STINNER Victor added the comment: > Changing the affected version to just 2.7. Oh. The request looks like an enhancement. The problem is that if you add a new feature in Python 2.7.n+1, it's not available on Python 2.7.n. Support 2.7.n as well, you have to backport the code in your

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-17 Thread Glyph Lefkowitz
Glyph Lefkowitz added the comment: Changing the affected version to just 2.7. -- versions: -Python 3.5, Python 3.6 ___ Python tracker ___

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-17 Thread Glyph Lefkowitz
Glyph Lefkowitz added the comment: It does seem to be stable on python 3, but on python 2.7 it's definitely a problem: $ python -Rc "import random; r=random.Random('abc'); print(''.join(map(str, (r.randrange(10) for x in range(10, hash('abc'))" ('9553343809', -1972659830997666042) $

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-17 Thread STINNER Victor
STINNER Victor added the comment: "Right now the way to work around this is to get some deterministic hash from your string; one mechanism being a truncated SHA256 hash, ..." It looks like I missed something. Lib/random.py already computes the SHA-512 hash of you pass a string to

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-14 Thread Terry J. Reedy
Terry J. Reedy added the comment: I agree with the value of a Reproducibility guarantee. (The new section appears to have been added -- by Raymond -- in 3.2.) For instance, people posting play-through videos using reproducible random maps typically post the 'seed' and I have seen memorable

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-11 Thread Nofar Schnider
Nofar Schnider added the comment: On it! -- nosy: +Nofar Schnider ___ Python tracker ___ ___ Python-bugs-list

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-08 Thread Cory Benfield
Changes by Cory Benfield : -- nosy: +Lukasa ___ Python tracker ___ ___ Python-bugs-list

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-07 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thanks for the bug report. This is a case of something that used to work fine but was affected by an incidental change elsewhere. To support the use case for deterministic sequences of values starting from a known point, the docs promise, "If a new

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-07 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> rhettinger nosy: +rhettinger ___ Python tracker ___

[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

2016-08-07 Thread Glyph Lefkowitz
New submission from Glyph Lefkowitz: The purpose of 'seeding' a random number generator is usually to supply a deterministic sequence of values starting from a known point. This works fine if you seed random.Random with an integer. Often (for example, see Minecraft's map generation