File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -223,14 +223,31 @@ def get_latex_manager():
223223 LatexManagerFactory .previous_instance = new_inst
224224 return new_inst
225225
226+ class WeakSet :
227+ # TODO: Poor man's weakref.WeakSet.
228+ # Remove this once python 2.6 support is dropped from matplotlib.
229+
230+ def __init__ (self ):
231+ self .weak_key_dict = weakref .WeakKeyDictionary ()
232+
233+ def add (self , item ):
234+ self .weak_key_dict [item ] = None
235+
236+ def discard (self , item ):
237+ if item in self .weak_key_dict :
238+ del self .weak_key_dict [item ]
239+
240+ def __iter__ (self ):
241+ return self .weak_key_dict .iterkeys ()
242+
226243
227244class LatexManager :
228245 """
229246 The LatexManager opens an instance of the LaTeX application for
230247 determining the metrics of text elements. The LaTeX environment can be
231248 modified by setting fonts and/or a custem preamble in the rc parameters.
232249 """
233- _unclean_instances = weakref . WeakSet ()
250+ _unclean_instances = WeakSet ()
234251
235252 @staticmethod
236253 def _build_latex_header ():
You can’t perform that action at this time.
0 commit comments