-
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
Tests failed on Arch Linux #84
Comments
@felixonmars if this is still an issue, can you please check against the latest 1.3.8 release? |
Yes, it's still present in 1.3.7/1.3.8 releases. Full logs w/versions: https://paste.xinu.at/HRD/ |
@felixonmars my first guess would be something is borked with the
in the |
It seems the lxml here has some issues with runpy, that it fails the second time running the same example:
Using |
Here is my findings. Put together a xml file and run this: from lxml import etree
import ctypes
xmlsec = ctypes.CDLL('/usr/lib/libxmlsec1.so')
xmlsec.xmlSecInit()
etree.parse('enc1-doc.xml')
print('ok')
etree.parse('enc1-doc.xml') It reproduces. The second lxml, xmlsec and libxml2 are all coming from my Arch Linux. It looks like the lxml wheel from PyPI (installed by pip) has its own libxml2, but xmlsec dynamically links to the system one, so xmlsec changes one libxml2 while lxml uses another, avoiding this issue. (But I don't know if it's OK to have two libxml2 libraries like this.) I don't know how to use the C libraries so no reproduction tries without Python. |
@lilydjwg your comment was of an immense help and it brought me on the right track, thank you! I found out that this issue is caused by from lxml import etree
import xmlsec
etree.parse('doc.xml', parser=etree.XMLParser())
etree.parse('doc.xml', parser=etree.XMLParser()) works, but from lxml import etree
import xmlsec
p = etree.XMLParser()
etree.parse('doc.xml', parser=p)
etree.parse('doc.xml', parser=p) raises. The same issue arises when calling The workaround to this issue is thus simple - resetting the default parser between the |
In the meantime, a simple patch like e.g. diff --git a/tests/base.py b/tests/base.py
index b05de1d..5ec356f 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -94,6 +94,7 @@ class TestMemoryLeaks(unittest.TestCase):
def load_xml(self, name, xpath=None):
"""returns xml.etree"""
+ etree.set_default_parser(parser=etree.XMLParser())
root = etree.parse(self.path(name)).getroot()
if xpath is None:
return root
diff --git a/tests/test_doc_examples.py b/tests/test_doc_examples.py
index 2fc490f..53d2377 100644
--- a/tests/test_doc_examples.py
+++ b/tests/test_doc_examples.py
@@ -42,3 +42,5 @@ def test_doc_example(example):
"""
with cd(example.parent):
runpy.run_path(str(example))
+ from lxml import etree
+ etree.set_default_parser(parser=etree.XMLParser()) will fix the test run, but I'm sure this is not what you're after in the end. |
For reference: https://bugs.launchpad.net/lxml/+bug/1880251 |
@hoefling, Thanks for the above solution. It will be helpful if the above mentioned changes are added or suggest if I am missing any installation of any other dependencies. |
@odidev if you're getting the same error with |
Follow-up issue: https://bugs.launchpad.net/lxml/+bug/1887848 |
https://build.opensuse.org/request/show/976452 by user mcepl + dimstar_suse - Update to 1.3.12: - Added support for registering custom xmlsec IO callbacks - Added support for building without MD5 transforms - Added support for PEP 539 for Python 3.7 and newer - Using lxml-stubs package instead of custom LXML stubs - Add avoid_lxml_tests_failing.patch (help working around the lxml issue lp#1880251 and lp#1887848, from gh#xmlsec/python-xmlsec#84). - Switch off building on Python 3.10 and %ix86 (gh#xmlsec/python-xmlsec#204).
There are still three failures here with 1.3.13 and lxml 4.9.1:
Looks like there's no activity on the follow-up lxml issue. |
I am trying to package python-xmlsec for Arch, but unfortunately most tests are failing here. Versions:
Python 3.6.6/3.7.0
libxml2 2.9.8
xmlsec 1.2.26
Cflags:
-DXMLSEC_CRYPTO_DYNAMIC_LOADING=1 -D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_SIZE_T -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_DL_LIBLTDL=1 -I/usr/include/xmlsec1 -I/usr/include/libxml2
Example test failure (others are very similar):
The text was updated successfully, but these errors were encountered: