diff --git a/src/fix.py b/src/fix.py index bc44244f4..87b679bdf 100644 --- a/src/fix.py +++ b/src/fix.py @@ -53,11 +53,14 @@ def choice(iterable): return _choice(iterable) else: n = 1 - ret = None + m = new.module('') # Guaranteed unique value. + ret = m for x in iterable: if random.random() < 1/n: ret = x n += 1 + if ret is m: + raise IndexError return ret random.choice = choice