old_contents: # encoding: utf-8
  from lxml.html import fromstring
  from lxml.etree import ParserError, XMLSyntaxError
  
  # return unicoded text which HTML tags are removed
  def text_content(html):
      try:
          return unicode(fromstring(html).text_content().strip())
      except ParserError, e:
          # asserted in case of being “</nav>” content
          return u''
      except XMLSyntaxError, e:
          return u''
new_contents: # encoding: utf-8
  from lxml.html import fromstring
  from lxml.etree import ParserError, XMLSyntaxError
  
  # return unicoded text which HTML tags are removed
  def text_content(html):
      try:
          dom = fromstring(html)
          if dom is not None:
              return unicode(dom.text_content().strip())
      except ParserError, e:
          # asserted in case of being “</nav>” content
          return u''
      except XMLSyntaxError, e:
          return u''
subject: fix FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.