Author: David Schneider <[email protected]>
Branch:
Changeset: r63860:6e75b7739261
Date: 2013-05-05 14:02 +0200
http://bitbucket.org/pypy/pypy/changeset/6e75b7739261/
Log: merge heads
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
@@ -33,8 +33,8 @@
elif space.isinstance_w(w_n, space.w_long):
w_n = space.abs(w_n)
else:
- # XXX not perfectly like CPython
- w_n = space.abs(space.hash(w_n))
+ n = space.hash_w(w_n)
+ w_n = space.wrap(r_uint(n))
key = []
w_one = space.newint(1)
w_two = space.newint(2)
diff --git a/pypy/module/_random/test/test_random.py
b/pypy/module/_random/test/test_random.py
--- a/pypy/module/_random/test/test_random.py
+++ b/pypy/module/_random/test/test_random.py
@@ -42,13 +42,14 @@
rnd1.setstate((-1, ) * 624 + (0, ))
def test_seed(self):
- import _random
+ import _random, sys
rnd = _random.Random()
rnd.seed()
different_nums = []
+ mask = sys.maxint * 2 + 1
for obj in ["spam and eggs", 3.14, 1+2j, 'a', tuple('abc')]:
nums = []
- for o in [obj, hash(obj), -hash(obj)]:
+ for o in [obj, hash(obj) & mask, -(hash(obj) & mask)]:
rnd.seed(o)
nums.append([rnd.random() for i in range(100)])
n1 = nums[0]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit