Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue32329

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:PYTHONHASHSEED=0 python3 -R should enable hash randomization
Type:Stage:resolved
Components:Versions:Python 3.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: vstinner
Priority:normalKeywords:patch

Created on2017-12-14 23:11 byvstinner, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 4873mergedvstinner,2017-12-14 23:16
PR 4875mergedvstinner,2017-12-15 00:00
PR 4884mergedvstinner,2017-12-15 15:00
Messages (5)
msg308343 -(view)Author: STINNER Victor (vstinner)*(Python committer)Date: 2017-12-14 23:11
Python pretends that hash randomization is always enabled, but it's not:$ PYTHONHASHSEED=0 python3 -c 'import sys; print(sys.flags.hash_randomization)'1vstinner@apu$ PYTHONHASHSEED=0 python3 -c 'import sys; print(hash("abc"))'4596069200710135518vstinner@apu$ PYTHONHASHSEED=0 python3 -c 'import sys; print(hash("abc"))'4596069200710135518vstinner@apu$ PYTHONHASHSEED=0 python3 -c 'import sys; print(hash("abc"))'4596069200710135518=> sys.flags.hash_randomization must be zeroMoreover, 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)'1vstinner@apu$ PYTHONHASHSEED=0 python3 -R -c 'import sys; print(hash("abc"))'4596069200710135518vstinner@apu$ PYTHONHASHSEED=0 python3 -R -c 'import sys; print(hash("abc"))'4596069200710135518vstinner@apu$ PYTHONHASHSEED=0 python3 -R -c 'import sys; print(hash("abc"))'4596069200710135518I expect that -R enables hash randomization and overrides PYTHONHASHSEED environment variable.Attached PR fixes these issues and adds an unit test.
msg308348 -(view)Author: STINNER Victor (vstinner)*(Python committer)Date: 2017-12-14 23:51
New changeset358e5e17a51ba00742bfaee4557a94c3c4179c22 by Victor Stinner in branch 'master':bpo-32329: Fix -R option for hash randomization (#4873)https://github.com/python/cpython/commit/358e5e17a51ba00742bfaee4557a94c3c4179c22
msg308354 -(view)Author: STINNER Victor (vstinner)*(Python committer)Date: 2017-12-15 00:39
New changeset22097aaa77b4f0473552fe840358d77e5b9a253f by Victor Stinner in branch '3.6':bpo-32329: Fix sys.flags.hash_randomization (#4875)https://github.com/python/cpython/commit/22097aaa77b4f0473552fe840358d77e5b9a253f
msg308355 -(view)Author: STINNER Victor (vstinner)*(Python committer)Date: 2017-12-15 00:43
"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.
msg308405 -(view)Author: STINNER Victor (vstinner)*(Python committer)Date: 2017-12-15 15:29
New changeset642d67b4f25262889b43f91ad2a96ca0e37fd5a2 by Victor Stinner in branch 'master':bpo-32329: Add versionchanged to -R option doc (#4884)https://github.com/python/cpython/commit/642d67b4f25262889b43f91ad2a96ca0e37fd5a2
History
DateUserActionArgs
2022-04-11 14:58:55adminsetgithub: 76510
2017-12-15 15:41:41vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-12-15 15:29:08vstinnersetmessages: +msg308405
2017-12-15 15:00:39vstinnersetpull_requests: +pull_request4780
2017-12-15 00:43:00vstinnersetmessages: +msg308355
2017-12-15 00:39:50vstinnersetmessages: +msg308354
2017-12-15 00:00:11vstinnersetpull_requests: +pull_request4769
2017-12-14 23:51:24vstinnersetmessages: +msg308348
2017-12-14 23:16:46vstinnersetkeywords: +patch
stage: patch review
pull_requests: +pull_request4766
2017-12-14 23:11:20vstinnercreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp