@@ -659,7 +659,7 @@ def find_or_create_context(self, widget, *args):
659659 of the context list."""
660660
661661 # First search the contexts that were already used in this widget instance
662- best_context , best_score = self .find_context (widget .context_settings , args )
662+ best_context , best_score = self .find_context (widget .context_settings , args , move_up = True )
663663 # If the exact data was used, reuse the context
664664 if best_score == self .PERFECT_MATCH :
665665 return best_context , False
@@ -675,7 +675,7 @@ def find_or_create_context(self, widget, *args):
675675 self .add_context (widget .context_settings , context )
676676 return context , best_context is None
677677
678- def find_context (self , known_contexts , args , best_score = 0 , best_context = None ):
678+ def find_context (self , known_contexts , args , best_score = 0 , best_context = None , move_up = False ):
679679 """Search the given list of contexts and return the context
680680 which best matches the given args.
681681
@@ -685,7 +685,8 @@ def find_context(self, known_contexts, args, best_score=0, best_context=None):
685685 for i , context in enumerate (known_contexts ):
686686 score = self .match (context , * args )
687687 if score == self .PERFECT_MATCH :
688- self .move_context_up (known_contexts , i )
688+ if move_up :
689+ self .move_context_up (known_contexts , i )
689690 return context , score
690691 if score > best_score : # NO_MATCH is not OK!
691692 best_context , best_score = context , score
@@ -1035,6 +1036,8 @@ def is_valid_item(self, setting, item, attrs, metas):
10351036 Subclasses can override this method to checks data in alternative
10361037 representations.
10371038 """
1039+ if not isinstance (item , tuple ):
1040+ return True
10381041 return self ._var_exists (setting , item , attrs , metas )
10391042
10401043
0 commit comments