etree.tostring() returns empty string

Bug #1556625 reported by Clayton Cafiero
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Invalid
Undecided
Unassigned

Bug Description

lxml.etree.tostring() is returning an empty string on valid etree Element

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")
>>> 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_info(major=2, minor=7, micro=10, releaselevel='final', serial=0)
>>> print("%-20s: %s" % ('lxml.etree', etree.LXML_VERSION))
lxml.etree : (3, 4, 4, 0)
>>> print("%-20s: %s" % ('libxml used', etree.LIBXML_VERSION))
libxml used : (2, 7, 6)
>>> print("%-20s: %s" % ('libxml compiled', etree.LIBXML_COMPILED_VERSION))
libxml compiled : (2, 9, 2)
>>> print("%-20s: %s" % ('libxslt used', etree.LIBXSLT_VERSION))
libxslt used : (1, 1, 28)
>>> print("%-20s: %s" % ('libxslt compiled', etree.LIBXSLT_COMPILED_VERSION))
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==3.2.1
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-SQLAlchemy==2.0
Flask-Testing==0.4.2
Flask-Uploads==0.1.3
Flask-WTF==0.12
funcsigs==0.4
itsdangerous==0.24
Jinja2==2.8
jmespath==0.7.1
lockfile==0.11.0
logilab-common==1.1.0
lxml==3.4.4
mando==0.3.3
MarkupSafe==0.23
marshmallow==2.2.0
marshmallow-sqlalchemy==0.6.0
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-daemon==2.0.6
python-dateutil==2.4.2
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

Revision history for this message
scoder (scoder) wrote : Re: [Bug 1556625] [NEW] etree.tostring() returns empty string

This seems suspicious:

> >>> print("%-20s: %s" % ('libxml used', etree.LIBXML_VERSION))
> libxml used : (2, 7, 6)
> >>> print("%-20s: %s" % ('libxml compiled', etree.LIBXML_COMPILED_VERSION))
> 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.

Revision history for this message
Clayton Cafiero (clayton-d) wrote :

Hi:

That makes sense. Issue resolved.

Thank you.

-C

scoder wrote:
> This seems suspicious:
>
>>>>> print("%-20s: %s" % ('libxml used', etree.LIBXML_VERSION))
>> libxml used : (2, 7, 6)
>>>>> print("%-20s: %s" % ('libxml compiled', etree.LIBXML_COMPILED_VERSION))
>> 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.
>

Clayton Cafiero / Desk: +1 802 735 0010 / Pocket: +1 802 735 8744 /
Skype: clayton.cafiero / LinkedIn: claytoncafiero
<http://www.linkedin.com/in/claytoncafiero>

------------------------------------------------------------------------

*Quercer & Janath, Inc.* / +1 802 735 0010 / Box 9366 / South
Burlington, VT 05407 U.S.A. / http://quercerjanath.com/ / Twitter
<https://twitter.com/QuercerJanath>

Please send support requests to <email address hidden> or visit our
help desk at https://qxj.zendesk.com/
<https://twitter.com/QuercerJanath>

scoder (scoder)
Changed in lxml:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.