Reusing the default XML parser raises an XMLSyntaxError
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Fix Released
|
Medium
|
scoder |
Bug Description
### Version info
Python : sys.version_
lxml.etree : (4, 5, 1, 0)
libxml used : (2, 9, 10)
libxml compiled : (2, 9, 10)
libxslt used : (1, 1, 34)
libxslt compiled : (1, 1, 34)
### Summary
If `libxmlsec1` is initialized, reusing the `etree.XMLParser` raises an `lxml.etree.
```python
from lxml import etree
import ctypes
xmlsec = ctypes.
xmlsec.xmlSecInit()
etree.parse(
etree.parse(
```
will yield
```
Traceback (most recent call last):
File "reader.py", line 23, in <module>
etree.
File "src/lxml/
File "src/lxml/
File "src/lxml/
File "src/lxml/
File "src/lxml/
File "src/lxml/
File "src/lxml/
File "src/lxml/
File "b'doc.xml'", line 0
lxml.etree.
```
The workarounds are:
* resetting the default XML parser object after each `etree.parse` invocation:
```python
etree.
etree.
```
* or passing a new `etree.XMLParser` instance explicitly:
```python
etree.
```
* or avoiding passing file name, e.g.
```python
etree.
```
as it seems that only this branch is affected: https:/
Changed in lxml: | |
status: | Fix Committed → Fix Released |
For greater readability: copy the text as-is and paste it in any markdown editor, e.g. https:/ /dillinger. io