Skip to content

repair non-namespace-aware attribute mis-interpretation in ElementTreeContentHandler #107

merged 2 commits into from Mar 31, 2013

2 participants

zzzeek commented Mar 30, 2013

this pull request allows the usage of non-NS aware SAX parsers to work properly with ElementTreeContentHandler, regarding attributes. This refers to

Summary test:

document = """<?xml version="1.0" encoding="utf-8"?>
    <Data FooBar="123">

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().

zzzeek added some commits Mar 29, 2013
@zzzeek zzzeek - repair issue in sax.ElementTreeContentHandler
whereby attributes passed to startElement() would be mis-interpreted
as containing a namespace attribute, leading to a TypeError,
as well as where attributes with namespaces wouldn't be split
up correctly when passed to startElement().
@zzzeek zzzeek - pass through non-NS aware attribute names as is; a ":" should just …
…go to

- use boolean test for attributes dict
lxml member
scoder commented Mar 31, 2013


@scoder scoder merged commit 103cd6c into lxml:master Mar 31, 2013

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.