diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-09-28 09:17:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-28 09:17:51 (GMT) |
commit | befc956acf8ddeb94f000ed081ddec51315429e5 (patch) | |
tree | cf34b0e10b6959622d7969bb43ad8f4bbb01553f /Lib | |
parent | 68b131d5b674549bb637b366730497714ad11328 (diff) | |
download | cpython-befc956acf8ddeb94f000ed081ddec51315429e5.zip cpython-befc956acf8ddeb94f000ed081ddec51315429e5.tar.gz cpython-befc956acf8ddeb94f000ed081ddec51315429e5.tar.bz2 |
[3.6] bpo-31478: Fix an assertion failure in random.seed() in case a seed has a bad __abs__() method. (GH-3596) (#3794)
(cherry picked from commit d780b2d588e68bd7047ef5d1f04e36da38b7a350)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_random.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index a2d9a96..b42bf2a 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -423,6 +423,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. |