This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: AssertionError: ElementTree not initialized, missing root
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: joseph.reagle, scoder, xtreak
Priority: normal Keywords:

Created on 2019-11-25 23:28 by joseph.reagle, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
index.html joseph.reagle, 2019-11-25 23:28
Messages (4)
msg357465 - (view) Author: Joseph Reagle (joseph.reagle) Date: 2019-11-25 23:28
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'})
```
msg357466 - (view) Author: Joseph Reagle (joseph.reagle) Date: 2019-11-25 23:30
Here's the error:

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "src/lxml/etree.pyx", line 2291, in lxml.etree._ElementTree.xpath
  File "src/lxml/etree.pyx", line 1869, in lxml.etree._ElementTree._assertHasRoot
AssertionError: ElementTree not initialized, missing root
```
msg357482 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-11-26 05:06
This seems more like an issue with lxml.
msg357494 - (view) Author: Joseph Reagle (joseph.reagle) Date: 2019-11-26 13:49
On 11/26/19 12:06 AM, Karthikeyan Singaravelan wrote:
> Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment:
> 
> This seems more like an issue with lxml.

I posted a report over there now too:

https://bugs.launchpad.net/lxml/+bug/1854057
History
Date User Action Args
2022-04-11 14:59:23adminsetgithub: 83091
2019-11-26 14:54:36scodersetstatus: open -> closed
resolution: third party
stage: resolved
2019-11-26 13:49:06joseph.reaglesetmessages: + msg357494
2019-11-26 05:06:06xtreaksetnosy: + xtreak, scoder
messages: + msg357482
2019-11-25 23:30:44joseph.reaglesetmessages: + msg357466
2019-11-25 23:28:54joseph.reaglecreate