diff options
| author | guido <guido@google.com> | 2011-03-29 12:02:49 -0700 |
|---|---|---|
| committer | guido <guido@google.com> | 2011-03-29 12:02:49 -0700 |
| commit | cea1c1161964fc314a0e3dd68e74ceb563fc528c (patch) | |
| tree | 89c6f150cb5aec505ea2e0e3df746f50b3e85050 /Lib/random.py | |
| parent | 7e603d1d2989bfb010d3641a3e152df13e0afbb0 (diff) | |
| parent | dff28659880a2ce62ef2c87dc7de58aaa86b85fc (diff) | |
| download | cpython-cea1c1161964fc314a0e3dd68e74ceb563fc528c.tar.gz | |
Merge Issue 11662 from 3.2 branch.
Diffstat (limited to 'Lib/random.py')
| -rw-r--r-- | Lib/random.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/random.py b/Lib/random.py index 7e0de4f6db..3d2af24d43 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -42,7 +42,7 @@ from types import MethodType as _MethodType, BuiltinMethodType as _BuiltinMethod from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin from os import urandom as _urandom -import collections as _collections +from collections.abc import Set as _Set, Sequence as _Sequence from hashlib import sha512 as _sha512 __all__ = ["Random","seed","random","uniform","randint","choice","sample", @@ -114,7 +114,7 @@ class Random(_random.Random): if version == 2: if isinstance(a, (str, bytes, bytearray)): if isinstance(a, str): - a = a.encode("utf8") + a = a.encode("utf-8") a += _sha512(a).digest() a = int.from_bytes(a, 'big') @@ -293,10 +293,10 @@ class Random(_random.Random): # preferred since the list takes less space than the # set and it doesn't suffer from frequent reselections. - if isinstance(population, _collections.Set): + if isinstance(population, _Set): population = tuple(population) - if not isinstance(population, _collections.Sequence): - raise TypeError("Population must be a sequence or Set. For dicts, use list(d).") + if not isinstance(population, _Sequence): + raise TypeError("Population must be a sequence or set. For dicts, use list(d).") randbelow = self._randbelow n = len(population) if not 0 <= k <= n: |
