lxml tostring() returns blank string in Flask running on mod-wsgi

可紊 提交于 2019-12-12 01:43:50

问题


I have a Python 2.7.6 Flask application that is trying to parse a SAML XML document using the lxml library. I'm running into an issue where etree.tostring(...) returns an empty string.

etree_string = etree.tostring(etree.fromstring(b'<test1><test2></test2></test1>'))
return etree_string
# output: ''

This appears to only occur when the code is run within the Flask app, served by mod_wsgi in Apache. I say this because in the same virtualenv, if I open a python interpreter and run:

>>> etree_string = etree.tostring(etree.fromstring(b'<test1><test2></test2></test1>'))
>>> print etree_string
<test1><test2/></test1>

Anyone have an idea on what might be going on?

来源:https://stackoverflow.com/questions/40599442/lxml-tostring-returns-blank-string-in-flask-running-on-mod-wsgi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!