sagemath/sagemath-random.patch
Jerry James 05337076b6 Update to sagemath 8.7.
- Drop upstreamed -giac patch.
- Add -sagetex patch to fix a python indentation error.
- Add -rubiks patch to fix compilation of the rubiks library.
- Add -random patch to fix a non-random random bit generator.
- Drop pip3 workaround; the binary is now named just pip again.
2019-04-28 15:12:00 -06:00

32 lines
1.3 KiB
Diff

diff -up src/sage/misc/binary_tree.pyx.orig src/sage/misc/binary_tree.pyx
--- src/sage/misc/binary_tree.pyx.orig 2019-03-23 16:20:41.000000000 -0600
+++ src/sage/misc/binary_tree.pyx 2019-04-09 13:55:17.152716497 -0600
@@ -13,6 +13,8 @@ from cysignals.memory cimport sig_malloc
from cpython.ref cimport PyObject, Py_INCREF, Py_XDECREF
+from sage.misc.prandom import randint
+
cdef binary_tree_node *BinaryTreeNode(int key, object value):
cdef binary_tree_node *t
t = <binary_tree_node *>sig_malloc(sizeof(binary_tree_node))
@@ -122,10 +124,7 @@ cdef binary_tree_node *binary_tree_right
cdef binary_tree_node *binary_tree_head_excise(binary_tree_node *self):
cdef binary_tree_node *cur
cdef int right
- # We have a pointer we're about to free. Chances are, we'll never
- # see this pointer again. Thus, its least significant bit is
- # "random" enough to resist bias.
- right = (<int>self)&1
+ right = randint(0, 1)
if self.right == NULL:
return self.left
if self.left == NULL:
@@ -502,7 +501,6 @@ class Test:
sage: sage.misc.binary_tree.Test().random()
"""
- from sage.misc.prandom import randint
t = BinaryTree()
for i in xrange(cycles):
r = randint(0,8)