mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
[3.9] bpo-41052: Opt out serialization/deserialization for _random.Random (GH-21002). (GH-21030)
(cherry picked from commit 6989af0bc7
)
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
This commit is contained in:
parent
71bb921829
commit
814b07bf81
4 changed files with 47 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue