[lxml-dev] Bugs in 1.0.beta
Hi list, On my box (Ubuntu Linux Dapper Drake on i686 / python2.4) all tests pass but running the bench scripts yields some problems:
lxml.etree.LIBXML_COMPILED_VERSION (2, 6, 24) lxml.etree.LIBXSLT_COMPILED_VERSION (1, 1, 15)
xpath_extensions_old and xslt_extensions_old trigger the following exceptions: lxe: xpath_extensions_old (-- T1 ) Traceback (most recent call last): File "bench.py", line 652, in ? result = run_bench(bench, *benchmark_setup) File "bench.py", line 606, in run_bench method_call(*args) File "bench.py", line 453, in bench_xpath_extensions_old xpath = self.etree.XPath("child(.)", extensions=extensions) File "xpath.pxi", line 166, in etree.XPath.__init__ File "xpath.pxi", line 53, in etree.XPathEvaluatorBase.__init__ File "xpath.pxi", line 17, in etree._XPathContext.__init__ File "extensions.pxi", line 45, in etree._BaseContext.__init__ TypeError: unindexable object lxe: xslt_extensions_old (-- T1 ) Traceback (most recent call last): File "bench.py", line 652, in ? result = run_bench(bench, *benchmark_setup) File "bench.py", line 606, in run_bench method_call(*args) File "bench.py", line 479, in bench_xslt_extensions_old transform = self.etree.XSLT(tree, extensions) File "xslt.pxi", line 265, in etree.XSLT.__init__ File "xslt.pxi", line 189, in etree._XSLTContext.__init__ File "extensions.pxi", line 45, in etree._BaseContext.__init__ ValueError: unpack sequence of wrong size And append_element and replace_children triggers segmentation faults. The first one crashed after child <Element {bcd}zzzzz at -48285674>. I don't have time to dig further right now. I'll have more time tonight. Best, -- Olivier
Hi Olivier, Olivier Grisel wrote:
On my box (Ubuntu Linux Dapper Drake on i686 / python2.4) all tests pass but running the bench scripts yields some problems:
lxml.etree.LIBXML_COMPILED_VERSION (2, 6, 24) lxml.etree.LIBXSLT_COMPILED_VERSION (1, 1, 15)
xpath_extensions_old and xslt_extensions_old trigger the following exceptions: [snip]
Ah, right, I forgot to fix those. Luckily, it's the benchmarks that are broken here, not lxml.
And append_element and replace_children triggers segmentation faults. The first one crashed after child <Element {bcd}zzzzz at -48285674>.
Thanks, I can reproduce those. I'll see what I can come up with. T'was a good idea to release a beta, after all... Thanks for the reports! Stefan
Hi Olivier, Olivier Grisel wrote:
On my box (Ubuntu Linux Dapper Drake on i686 / python2.4) all tests pass but running the bench scripts yields some problems: [snip] append_element and replace_children triggers segmentation faults. The first one crashed after child <Element {bcd}zzzzz at -48285674>.
It took me a while to track down this bug, as it was absolutely not where the benchmark code suggested. The test case that triggers it is:
a = Element('a') b = copy.deepcopy(a) b.append( Element('c') ) del b
The problem lies in the modified Element.__copy__() method I wrote. Instead of creating a new document for the copied tree, it tried to copy the original document structure to keep its settings. I now found that this additionally requires copying the pointer to the parser dictionary also, otherwise libxml2 ends up freeing still-in-use entries from it when deallocating the copied nodes... Things like this tend to remind me of one of the major reasons for having lxml: *one* place to get this stuff right is just so enough... To prevent further bugs like this, I wrote a new helper function _copyDoc that copies the document and sets the dict, and a convenience function _copyDocRoot that makes a specific node the new root node in the copied document (using fakeRootDoc before copying). The bug is now fixed on the trunk. I also updated a couple of places in xslt.pxi where documents are copied, just in case... Stefan
participants (2)
-
Olivier Grisel
-
Stefan Behnel