-
Notifications
You must be signed in to change notification settings - Fork 99
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
importing xmlsec breaks second lxml.etree.parse call #96
Comments
I have seen the same on Centos 7. It forced us to use pyxmlsec instead of python-xmlsec which forces us to stick with Python2! It is worth noting that with pyxmlsec, if olxml eltree can also give problems in some cases. Though that seems to be linked to when an error hanlder is invoked and cases python to segfault. It might be a separate problem in pyxmlsec or it might an indication of an underlying probem in lxml , libxmlsec or libxml2. |
I can't reproduce this issue with the latest 1.3.8 anymore: $ podman run --rm -it registry.centos.org/centos:7
# yum update
# yum group install "Development Tools"
# yum install python3-devel python3-pip libxml2-devel xmlsec1-devel xmlsec1-openssl-devel libtool-ltdl-devel
# pip3 install xmlsec==1.3.8
# echo '<data/>' > sf.xml
# echo "from lxml import etree
import xmlsec
xml1 = etree.parse('sf.xml')
print(xml1)
xml2 = etree.parse('sf.xml')
print(xml2)
" > sf.py
# python3 sf.py
<lxml.etree._ElementTree object at 0x7f97438e9700>
<lxml.etree._ElementTree object at 0x7f9742dacfc0> Ping me if this issue should be reopened though! |
Nope, not resolved - I've tested with the |
It looks like an etree.parse('doc.xml')
etree.set_default_parser(parser=etree.XMLParser())
etree.parse('doc.xml') or pass a new parser instance explicitly: etree.parse('doc.xml', parser=etree.XMLParser())
etree.parse('doc.xml', parser=etree.XMLParser()) |
For reference: https://bugs.launchpad.net/lxml/+bug/1880251 |
self-tests of
used versions:
though the workaround you proposed works: --- a/tests/base.py
+++ b/tests/base.py
@@ -99,10 +99,11 @@ class TestMemoryLeaks(unittest.TestCase):
def load_xml(self, name, xpath=None):
"""returns xml.etree"""
- root = etree.parse(self.path(name)).getroot()
- if xpath is None:
- return root
- return root.find(xpath)
+ with open(self.path(name)) as f:
+ root = etree.parse(f).getroot()
+ if xpath is None:
+ return root
+ return root.find(xpath)
def dump(self, root):
print(etree.tostring(root)) |
When
is added to trivial python code which uses
lxml
'setree.parse
, the secondetree.parse
fails.Let's have minimal XML file
sf.xml
containingLet's have trivial code
sf.py
Running it with
python3 sf.py
produces two objects:However, when that
import xmlsec
is uncommented, the behaviour changes toThis is with
xmlsec
that was installed viapip3
on Fedora 28:This is upstream version of Fedora bug https://bugzilla.redhat.com/show_bug.cgi?id=1665459. With
xmlsec
installed viapip3
I don't get that segfault ... but note that the traceback ends with empty line, where some error message ("cannot parse file") would be expected.The text was updated successfully, but these errors were encountered: