etree.tostring() returns empty string
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Invalid
|
Undecided
|
Unassigned |
Bug Description
lxml.etree.
Python 2.7.10, lxml 3.4.4
$ python
[GCC 4.7.4] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
>>> foo = etree.Element(
>>> foo
<Element foo at 0xfe924fac>
>>> foo.tag
'foo'
>>> foo.text = "bar"
>>> foo.text
'bar'
>>> etree.tostring(foo)
''
>>>
This should produce
<foo>bar</foo>
?
Here is information required for bug report:
>>> print("%-20s: %s" % ('Python', sys.version_info))
Python : sys.version_
>>> print("%-20s: %s" % ('lxml.etree', etree.LXML_
lxml.etree : (3, 4, 4, 0)
>>> print("%-20s: %s" % ('libxml used', etree.LIBXML_
libxml used : (2, 7, 6)
>>> print("%-20s: %s" % ('libxml compiled', etree.LIBXML_
libxml compiled : (2, 9, 2)
>>> print("%-20s: %s" % ('libxslt used', etree.LIBXSLT_
libxslt used : (1, 1, 28)
>>> print("%-20s: %s" % ('libxslt compiled', etree.LIBXSLT_
libxslt compiled : (1, 1, 28)
In case it's helpful, here's pip freeze from the virtualenv in use:
astroid==1.3.8
awscli==1.7.45
baluhn==0.1
BeautifulSoup=
blinker==1.4
botocore==1.1.8
chardet==2.3.0
CherryPy==3.8.0
colorama==0.3.3
coverage==4.0
cssmin==0.2.0
docutils==0.12
ecdsa==0.13
Flask==0.10.1
Flask-Mail==0.9.1
Flask-Menu==0.4.0
Flask-Script==2.0.5
Flask-SQLAlchem
Flask-Testing=
Flask-Uploads=
Flask-WTF==0.12
funcsigs==0.4
itsdangerous==0.24
Jinja2==2.8
jmespath==0.7.1
lockfile==0.11.0
logilab-
lxml==3.4.4
mando==0.3.3
MarkupSafe==0.23
marshmallow==2.2.0
marshmallow-
mock==1.3.0
MySQL-python==1.2.5
nose==1.3.7
paramiko==1.16.0
pbr==1.8.0
pep8==1.6.2
pidfile==0.1.1
pika==0.10.0
py==1.4.30
pyasn1==0.1.8
pycrypto==2.6.1
pyflakes==1.0.0
pygal==1.1.0
Pygments==2.0.2
PyJWT==1.4.0
pylint==1.4.4
pysftp==0.2.8
pytest==2.8.0
python-
python-
pytz==2015.4
radon==1.2.2
rfc3987==1.3.4
rjsmin==1.0.10
rsa==3.1.4
simplejson==3.3.0
six==1.10.0
SQLAlchemy==1.0.8
urldecode==0.1
webassets==0.11.1
Werkzeug==0.11.2
WTForms==2.0.2
xlrd==0.9.4
Changed in lxml: | |
status: | New → Invalid |
This seems suspicious:
> >>> print("%-20s: %s" % ('libxml used', etree.LIBXML_ VERSION) ) COMPILED_ VERSION) )
> libxml used : (2, 7, 6)
> >>> print("%-20s: %s" % ('libxml compiled', etree.LIBXML_
> libxml compiled : (2, 9, 2)
You are using a much older libxml2 version at runtime than what you
compiled against. I wonder why that works at all, but assuming that it
really doesn't just fail to import entirely, I'd recommend against doing that.