lxml/lxml — pull request #107 by zzzeek (2013-03-30 18:08:44+00:00)
Title: repair non-namespace-aware attribute mis-interpretation in ElementTreeContentHandler

this pull request allows the usage of non-NS aware SAX parsers to work properly with ElementTreeContentHandler, regarding attributes. This refers to https://bugs.launchpad.net/lxml/+bug/1136509.

Summary test:

document = """

"""

from lxml import sax
from xml.sax import parse
from StringIO import StringIO

parse(StringIO(document), sax.ElementTreeContentHandler())

Above, the non-namespace aware parser generated by xml.sax.parse() calls the startElement() method, which ElementTreeContentHandler refers to startElementNS(). The attribute "FooBar" however must be expanded to the form `(None, "FooBar"): "123"` in order to be interpreted correctly by startElementNS().