From 047755f203393235e68ba07614280939a5309857 2014-04-03 23:26:43 From: jdavidheiser Date: 2014-04-03 23:26:43 Subject: [PATCH] widget_selection update Fix for the fact that dictionary randomization sometimes switches the order of the arguments passed to the class on initialization. This means that, potentially, 'value' can be updated BEFORE 'values', and since the method to update 'value' checks to see whether it exists in 'values', this breaks things. --- diff --git a/IPython/html/widgets/widget_selection.py b/IPython/html/widgets/widget_selection.py index aa3f194..7807fe6 100644 --- a/IPython/html/widgets/widget_selection.py +++ b/IPython/html/widgets/widget_selection.py @@ -59,6 +59,10 @@ class _SelectionWidget(DOMWidget): if isinstance(values, list): # preserve list order with an OrderedDict kwargs['values'] = OrderedDict((unicode_type(v), v) for v in values) + # python3.3 turned on hash randomization by default - this means that sometimes, randomly + # we try to set value before setting values, due to dictionary ordering. To fix this, force + # the setting of self.values right now, before anything else runs + self.values = kwargs['values'] DOMWidget.__init__(self, *args, **kwargs) def _values_changed(self, name, old, new):