code: def filter_completions(self, completions):
          
          # On Python 2, we have to make sure all completions are unicode objects before we continue and output them.
          # Otherwise, because python disobeys the system locale encoding and uses ascii as the default encoding, it will
          # try to implicitly decode string objects using ascii, and fail.
          completions = [ensure_str(c) for c in completions]
  
          # De-duplicate completions and remove excluded ones
          if self.exclude is None:
              self.exclude = set()
          seen = set(self.exclude)
          return [c for c in completions if c not in seen and not seen.add(c)]
docs: Ensures collected completions are Unicode text, de-duplicates them, and excludes those specified by ``exclude``.
          Returns the filtered completions as an iterable.
  
          This method is exposed for overriding in subclasses; there is no need to use it directly.