Wie bringt man BeautifulSoup 4 dazu, ein sich selbst schließendes Tag zu respektieren?

Diese Frage ist spezifisch fürBeautifulSoup4, was es von den vorherigen Fragen unterscheidet:

Warum ändert BeautifulSoup meine selbstschließenden Elemente?

selfClosingTags in BeautifulSoup

Schon seitBeautifulStoneSoup ist weg (der vorherige XML-Parser), wie kann ich bekommenbs4 ein neues selbstschließendes Tag zu respektieren? Zum Beispiel:

import bs4   
S = '''<foo> <bar a="3"/> </foo>'''
soup = bs4.BeautifulSoup(S, selfClosingTags=['bar'])

print soup.prettify()

Schließt das nicht selbstbar tag, gibt aber einen Hinweis. Auf welchen Tree Builder bezieht sich bs4 und wie schließe ich das Tag selbst?

/usr/local/lib/python2.7/dist-packages/bs4/__init__.py:112: UserWarning: BS4 does not respect the selfClosingTags argument to the BeautifulSoup constructor. The tree builder is responsible for understanding self-closing tags.
  "BS4 does not respect the selfClosingTags argument to the "
<html>
 <body>
  <foo>
   <bar a="3">
   </bar>
  </foo>
 </body>
</html>

Antworten auf die Frage(1)

Ihre Antwort auf die Frage