[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results

2020-10-15 Thread Xavier Morel
Xavier Morel added the comment: @rhettinger checking software against 3.9 there's a little issue with the way the check is done: if passed something which is *both* a sequence and a set (e.g. an ordered set), `random.sample` will trigger a warning, which I don't think is correct. Should I

[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results

2020-04-19 Thread Yuval S
Change by Yuval S : -- pull_requests: +18932 pull_request: https://github.com/python/cpython/pull/19596 ___ Python tracker ___ ___

[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results

2020-04-19 Thread Yuval S
Yuval S added the comment: Thank you for the attention and the quick fix. However, the current documentation for "Notes on Reproducibility" should still address this issue of hash randomization. Not only `sample` is affected by this, but any code that combines strings (or bytes or datetime)

[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results

2020-04-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: Yuval, thanks for the report. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results

2020-04-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 4fe002045fcf40823154b709fef0948b2bc5e934 by Raymond Hettinger in branch 'master': bpo-40325: Deprecate set object support in random.sample() (GH-19591) https://github.com/python/cpython/commit/4fe002045fcf40823154b709fef0948b2bc5e934

[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results

2020-04-18 Thread Raymond Hettinger
Change by Raymond Hettinger : -- keywords: +patch pull_requests: +18926 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19591 ___ Python tracker

[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results

2020-04-18 Thread Tim Peters
Tim Peters added the comment: Yup, I agree sample(set) is a misfeature. -- ___ Python tracker ___ ___ Python-bugs-list mailing

[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results

2020-04-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: I think the thing we can fix is the automatic set support which is intrinsically broken with respect to reproducibility and which was likely not a good idea to begin with (because it adds an implicit and possibly unexpected O(n) conversion step and

[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results

2020-04-18 Thread Tim Peters
Tim Peters added the comment: Raymond, I think that removing sample(set) support is a different issue. This report will just change its final example line to >>> print(random.sample(list(x), 1)) or >>> print(random.sample(tuple(x), 1)) and have the same complaint. -- nosy:

[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results

2020-04-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'm going to deprecate the support for sets. It was a design mistake at several levels. Better to just remove it. -- assignee: docs@python -> rhettinger nosy: +rhettinger type: -> behavior versions: +Python 3.9 -Python 3.7, Python 3.8

[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results

2020-04-18 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: String hash randomization is a security feature so it may be better to not disable it unless explicitly asked for. Maybe a note in random's documentation could be added? -- nosy: +remi.lapeyre ___ Python tracker

[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results

2020-04-18 Thread Yuval S
New submission from Yuval S : The following code gives different results on each run, even though "``random.seed()``" is used: >>> import random >>> random.seed(6) >>> x = set(str(i) for i in range(500)) >>> print(random.sample(x, 1)) presumably because of string hash randomization (see also