[lxml-dev] tostring(None) Segfaults with 0.7
# python Python 2.4.1 (#1, Jun 2 2005, 01:24:02) [GCC 2.95.4 20011002 (Debian prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import lxml.etree xmldoc = lxml.etree.fromstring('<section></section>') omlnode = xmldoc.find('oml') type(omlnode) <type 'NoneType'> lxml.etree.tostring(omlnode) Violación de segmento
-- dharana
Just for the record, for what I need it works, but it's easier to catch an exception than a segfault :)
import lxml.etree xmldoc = lxml.etree.fromstring('<?xml version="1.0"?><req><oml><section></section></oml><callback>update_preview_code</callback></req>') omlnode = xmldoc.find('oml') lxml.etree.tostring(omlnode) '<oml><section/></oml>'
dharana wrote:
# python Python 2.4.1 (#1, Jun 2 2005, 01:24:02) [GCC 2.95.4 20011002 (Debian prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import lxml.etree xmldoc = lxml.etree.fromstring('<section></section>') omlnode = xmldoc.find('oml') type(omlnode) <type 'NoneType'> lxml.etree.tostring(omlnode) Violación de segmento
-- dharana
dharana wrote:
# python Python 2.4.1 (#1, Jun 2 2005, 01:24:02) [GCC 2.95.4 20011002 (Debian prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import lxml.etree xmldoc = lxml.etree.fromstring('<section></section>') omlnode = xmldoc.find('oml') type(omlnode) <type 'NoneType'> lxml.etree.tostring(omlnode) Violación de segmento
Okay, it shouldn't segfault when it doesn't get a node but None instead. I need to check what ElementTree does and mimic this behavior. :) Regards, Martijn
Martijn Faassen wrote:
dharana wrote:
# python Python 2.4.1 (#1, Jun 2 2005, 01:24:02) [GCC 2.95.4 20011002 (Debian prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import lxml.etree xmldoc = lxml.etree.fromstring('<section></section>') omlnode = xmldoc.find('oml') type(omlnode) <type 'NoneType'> lxml.etree.tostring(omlnode) Violación de segmento
Okay, it shouldn't segfault when it doesn't get a node but None instead. I need to check what ElementTree does and mimic this behavior. :)
Fixed now on svn; it raises an AssertionError now. Thanks for the bug report! Regards, Martijn
participants (2)
-
dharana
-
Martijn Faassen