You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PYTHONHASHSEED=0 python3 -R should enable hash randomization #76510
"PYTHONHASHSEED=0 python3 -R" now enables hash randomization on master (Python 3.7), I also fixed the sys.flags.hash_randomization value when using PYTHONHASHSEED=0.
I chose to not modify the behaviour of the -R option in Python 3.6. I dislike having to document a behaviour change in a minor Python version (3.6.x). I only fixed the value of sys.flags.hash_randomization in Python 3.6.
Activity
vstinner commentedon Dec 14, 2017
Python pretends that hash randomization is always enabled, but it's not:
=> sys.flags.hash_randomization must be zero
Moreover, the -R flag is always ignored, it's not possible to override the PYTHONHASHSEED environment variable:
vstinner@apu$ PYTHONHASHSEED=0 python3 -R -c 'import sys; print(sys.flags.hash_randomization)'
1
vstinner@apu$ PYTHONHASHSEED=0 python3 -R -c 'import sys; print(hash("abc"))'
4596069200710135518
vstinner@apu$ PYTHONHASHSEED=0 python3 -R -c 'import sys; print(hash("abc"))'
4596069200710135518
vstinner@apu$ PYTHONHASHSEED=0 python3 -R -c 'import sys; print(hash("abc"))'
4596069200710135518
I expect that -R enables hash randomization and overrides PYTHONHASHSEED environment variable.
Attached PR fixes these issues and adds an unit test.
vstinner commentedon Dec 14, 2017
New changeset 358e5e1 by Victor Stinner in branch 'master':
bpo-32329: Fix -R option for hash randomization (bpo-4873)
358e5e1
vstinner commentedon Dec 15, 2017
New changeset 22097aa by Victor Stinner in branch '3.6':
bpo-32329: Fix sys.flags.hash_randomization (bpo-4875)
22097aa
vstinner commentedon Dec 15, 2017
"PYTHONHASHSEED=0 python3 -R" now enables hash randomization on master (Python 3.7), I also fixed the sys.flags.hash_randomization value when using PYTHONHASHSEED=0.
I chose to not modify the behaviour of the -R option in Python 3.6. I dislike having to document a behaviour change in a minor Python version (3.6.x). I only fixed the value of sys.flags.hash_randomization in Python 3.6.
vstinner commentedon Dec 15, 2017
New changeset 642d67b by Victor Stinner in branch 'master':
bpo-32329: Add versionchanged to -R option doc (bpo-4884)
642d67b