[New-bugs-announce] [issue38910] AssertionError: ElementTree not initialized, missing root
Joseph Reagle
report at bugs.python.org
Mon Nov 25 18:28:54 EST 2019
New submission from Joseph Reagle <joseph.2011 at reagle.org>:
I've attached a simple XHTML file with which the 3.8 interpreter throws an error on the following code, but 3.7 does not. (You'll have to change the path in the code below.)
```
from io import StringIO, BytesIO
from lxml import etree
import os
import readline
HOME = os.path.expanduser("~")
ofile = HOME + '/data/2web/reagle.org/joseph/plan/plans/index.html'
plan_fd = open(ofile, 'r', encoding='utf-8', errors='replace')
plan_content = plan_fd.read()
plan_fd.close()
plan_tree = etree.parse(StringIO(plan_content),
etree.XMLParser(ns_clean=True, recover=True))
ul_found = plan_tree.xpath(
'''//x:div[@id='Done']/x:ul''',
namespaces={'x': 'http://www.w3.org/1999/xhtml'})
```
----------
components: Library (Lib)
files: index.html
messages: 357465
nosy: joseph.reagle
priority: normal
severity: normal
status: open
title: AssertionError: ElementTree not initialized, missing root
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file48742/index.html
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38910>
_______________________________________
More information about the New-bugs-announce
mailing list