mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
bpo-31478: Fix an assertion failure in random.seed() in case a seed has a bad __abs__() method. (#3596)
This commit is contained in:
parent
db50ba7c72
commit
d780b2d588
3 changed files with 18 additions and 2 deletions
|
@ -430,6 +430,17 @@ class MersenneTwister_TestBasicOps(TestBasicOps, unittest.TestCase):
|
|||
['0x1.b0580f98a7dbep-1', '0x1.84129978f9c1ap-1',
|
||||
'0x1.aeaa51052e978p-2', '0x1.092178fb945a6p-2'])
|
||||
|
||||
def test_bug_31478(self):
|
||||
# There shouldn't be an assertion failure in _random.Random.seed() in
|
||||
# case the argument has a bad __abs__() method.
|
||||
class BadInt(int):
|
||||
def __abs__(self):
|
||||
return None
|
||||
try:
|
||||
self.gen.seed(BadInt())
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
def test_bug_31482(self):
|
||||
# Verify that version 1 seeds are unaffected by hash randomization
|
||||
# when the seeds are expressed as bytes rather than strings.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue