sagemath/sagemath-random.patch
Jerry James 861d3bcc88 Version 9.2 (bz 1891244)
- Unbundle widgetsnbextension (bz 1856311)
- Unbundle mathjax fonts (bz 1875606)
- Do not require the -doc subpackage from the main package (bz 1867123)
- Drop upstreamed patches: -ecl, -fes, -includes, -sagetex, -sigfpe, -sympy
2020-11-11 16:28:59 -07: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 2020-10-24 11:37:59.000000000 -0600
+++ src/sage/misc/binary_tree.pyx 2020-10-30 13:27:44.173427025 -0600
@@ -12,6 +12,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))
@@ -121,10 +123,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:
@@ -501,7 +500,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)