Message308343
Python pretends that hash randomization is always enabled, but it's not:
$ PYTHONHASHSEED=0 python3 -c 'import sys; print(sys.flags.hash_randomization)'
1
vstinner@apu$ PYTHONHASHSEED=0 python3 -c 'import sys; print(hash("abc"))'
4596069200710135518
vstinner@apu$ PYTHONHASHSEED=0 python3 -c 'import sys; print(hash("abc"))'
4596069200710135518
vstinner@apu$ PYTHONHASHSEED=0 python3 -c 'import sys; print(hash("abc"))'
4596069200710135518
=> 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. |
|
Date |
User |
Action |
Args |
2017-12-14 23:11:20 | vstinner | set | recipients:
+ vstinner |
2017-12-14 23:11:20 | vstinner | set | messageid: <1513293080.01.0.213398074469.issue32329@psf.upfronthosting.co.za> |
2017-12-14 23:11:19 | vstinner | link | issue32329 messages |
2017-12-14 23:11:19 | vstinner | create | |
|