aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_random.py
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2020-06-21 18:44:58 +0900
committerGitHub <noreply@github.com>2020-06-21 18:44:58 +0900
commit6989af0bc7ea1e9a1acea16794e6f723d7b44110 (patch)
tree7a6a51cf05c62572ace0e1420cfa4a0317752931 /Lib/test/test_random.py
parentf9bab74d5b34c64cf061e1629ff5f3092a4ca9b3 (diff)
downloadcpython-6989af0bc7ea1e9a1acea16794e6f723d7b44110.tar.gz
cpython-6989af0bc7ea1e9a1acea16794e6f723d7b44110.zip
bpo-41052: Opt out serialization/deserialization for _random.Random (GH-21002)
Diffstat (limited to 'Lib/test/test_random.py')
-rw-r--r--Lib/test/test_random.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index a3710f4aa48..a80e71e67e4 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -5,6 +5,8 @@ import os
import time
import pickle
import warnings
+import test.support
+
from functools import partial
from math import log, exp, pi, fsum, sin, factorial
from test import support
@@ -372,6 +374,14 @@ class TestBasicOps:
restoredseq = [newgen.random() for i in range(10)]
self.assertEqual(origseq, restoredseq)
+ @test.support.cpython_only
+ def test_bug_41052(self):
+ # _random.Random should not be allowed to serialization
+ import _random
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ r = _random.Random()
+ self.assertRaises(TypeError, pickle.dumps, r, proto)
+
def test_bug_1727780(self):
# verify that version-2-pickles can be loaded
# fine, whether they are created on 32-bit or 64-bit