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

merged 2 commits into from Mar 31, 2013


None yet
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

- 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().
- pass through non-NS aware attribute names as is; a ":" should just …
…go to

- use boolean test for attributes dict

This comment has been minimized.

Show comment
Hide comment

scoder Mar 31, 2013




scoder commented Mar 31, 2013


scoder added a commit that referenced this pull request Mar 31, 2013

Merge pull request #107 from zzzeek/master
repair non-namespace-aware attribute mis-interpretation in ElementTreeContentHandler

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

1 check passed

default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment