[pypy-commit] pypy stdlib-2.7.11: Check an error case in random
alex_gaynor
pypy.commits at gmail.com
Sun Mar 20 10:52:16 EDT 2016
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: stdlib-2.7.11
Changeset: r83192:29e976bd194a
Date: 2016-03-20 10:51 -0400
http://bitbucket.org/pypy/pypy/changeset/29e976bd194a/
Log: Check an error case in random
diff --git a/pypy/module/_random/interp_random.py b/pypy/module/_random/interp_random.py
--- a/pypy/module/_random/interp_random.py
+++ b/pypy/module/_random/interp_random.py
@@ -75,7 +75,10 @@
w_item = space.add(w_item, w_add)
self._rnd.state[i] = space.uint_w(w_item)
w_item = space.getitem(w_state, space.newint(rrandom.N))
- self._rnd.index = space.int_w(w_item)
+ index = space.int_w(w_item)
+ if index < 0 or index > rrandom.N:
+ raise OperationError(space.w_ValueError, "invalid state")
+ self._rnd.index = index
def jumpahead(self, space, w_n):
if space.isinstance_w(w_n, space.w_long):
More information about the pypy-commit
mailing list