summaryrefslogtreecommitdiffstats
path: root/Python/random.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-12-15 00:39:48 (GMT)
committerGitHub <noreply@github.com>2017-12-15 00:39:48 (GMT)
commit22097aaa77b4f0473552fe840358d77e5b9a253f (patch)
treed0c88308e105a22644230d8ec32a61791dd85bec /Python/random.c
parentd1cb1067a82b11280204e36b695e786a5a3ca221 (diff)
downloadcpython-22097aaa77b4f0473552fe840358d77e5b9a253f.zip
cpython-22097aaa77b4f0473552fe840358d77e5b9a253f.tar.gz
cpython-22097aaa77b4f0473552fe840358d77e5b9a253f.tar.bz2
bpo-32329: Fix sys.flags.hash_randomization (#4875)
sys.flags.hash_randomization is now properly set to 0 when hash randomization is turned off by PYTHONHASHSEED=0.
Diffstat (limited to 'Python/random.c')
-rw-r--r--Python/random.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/random.c b/Python/random.c
index c97d5e7..e0ee153 100644
--- a/Python/random.c
+++ b/Python/random.c
@@ -565,9 +565,11 @@ _PyRandom_Init(void)
if (seed == 0) {
/* disable the randomized hash */
memset(secret, 0, secret_size);
+ Py_HashRandomizationFlag = 0;
}
else {
lcg_urandom(seed, secret, secret_size);
+ Py_HashRandomizationFlag = 1;
}
}
else {
@@ -582,6 +584,7 @@ _PyRandom_Init(void)
if (res < 0) {
Py_FatalError("failed to get random numbers to initialize Python");
}
+ Py_HashRandomizationFlag = 1;
}
}