Skip to content

AttributeError: 'TreeWalker' object has no attribute 'fragmentChildren' #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
paradoxxxzero opened this issue Mar 3, 2016 · 2 comments
Milestone

Comments

@paradoxxxzero
Copy link
Contributor

For some reason my tree (lxml.etree._Element) object has no attribute getroot and is not a list so there is no fragmentChildren attribute on TreeWalker: 270a2ca

lxml 3.5.0
html5lib-python f796cca

@gsnedders
Copy link
Member

Where does your tree object come from? (We should probably add an assert False, "unreachable" there.)

@paradoxxxzero
Copy link
Contributor Author

I narrowed down the problem to:

from lxml.html import fromstring
from html5lib import treewalkers, serializer


lxmltree = fromstring('<div><div></div></div>')
walker = treewalkers.getTreeWalker('lxml')
stream = walker(lxmltree)
s = serializer.htmlserializer.HTMLSerializer()
output = s.render(stream)

Which gives:

Traceback (most recent call last):
  File "html5fail.py", line 9, in <module>
    output = s.render(stream)
  File "<path>/html5lib-python/html5lib/serializer/htmlserializer.py", line 306, in render
    return "".join(list(self.serialize(treewalker)))
  File "<path>/html5lib-python/html5lib/serializer/htmlserializer.py", line 196, in serialize
    for token in treewalker:
  File "<path>/html5lib-python/html5lib/filters/optionaltags.py", line 17, in __iter__
    for previous, token, next in self.slider():
  File "<path>/html5lib-python/html5lib/filters/optionaltags.py", line 9, in slider
    for token in self.source:
  File "<path>/html5lib-python/html5lib/treewalkers/_base.py", line 150, in __iter__
    currentNode = self.getParentNode(currentNode)
  File "<path>/html5lib-python/html5lib/treewalkers/lxmletree.py", line 202, in getParentNode
    elif node in self.fragmentChildren:
AttributeError: 'TreeWalker' object has no attribute 'fragmentChildren'

Python 3.5.1

@gsnedders gsnedders modified the milestone: 0.99999999 May 8, 2016
gsnedders added a commit to gsnedders/html5lib-python that referenced this issue May 22, 2016
gsnedders added a commit to gsnedders/html5lib-python that referenced this issue May 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants