Message308343
| Author |
vstinner |
| Recipients |
vstinner |
| Date |
2017年12月14日.23:11:19 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1513293080.01.0.213398074469.issue32329@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| 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 |
|