In Python 2.5 and 2.6, as well as in the standalone ElementTree module, etree.Element is a factory function, not a class.
Reference:
http://effbot.org/zone/pythondoc-elementtree-ElementTree.htm#elementtree.ElementTree.Element-function
[bugs:#200] odf writer fails when run with Python3.3b1
Status: open
Created: Tue Aug 07, 2012 07:32 PM UTC by Anonymous
Last Updated: Thu May 16, 2013 09:02 PM UTC
Owner: nobody
A few of the tests in test_writers.test_odt.DocutilsOdtTestCase fail when run against Python 3.3b1, with tracebacks of the form:
======================================================================
ERROR: test_odt_basic (test_writers.test_odt.DocutilsOdtTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/david/coding/python3.3/python-docutils/python3-python-docutils-0.10-0.2.20120730svn7490.fc18/test3/test_writers/test_odt.py", line 151, in test_odt_basic
self.process_test('odt_basic.txt', 'odt_basic.odt',
File "/home/david/coding/python3.3/python-docutils/python3-python-docutils-0.10-0.2.20120730svn7490.fc18/test3/test_writers/test_odt.py", line 104, in process_test
settings_overrides=settings_overrides)
File "/home/david/coding/python3.3/python-docutils/python3-python-docutils-0.10-0.2.20120730svn7490.fc18/build/lib/docutils/core.py", line 414, in publish_string
enable_exit_status=enable_exit_status)
File "/home/david/coding/python3.3/python-docutils/python3-python-docutils-0.10-0.2.20120730svn7490.fc18/build/lib/docutils/core.py", line 662, in publish_programmatically
output = pub.publish(enable_exit_status=enable_exit_status)
File "/home/david/coding/python3.3/python-docutils/python3-python-docutils-0.10-0.2.20120730svn7490.fc18/build/lib/docutils/core.py", line 219, in publish
output = self.writer.write(self.document, self.destination)
File "/home/david/coding/python3.3/python-docutils/python3-python-docutils-0.10-0.2.20120730svn7490.fc18/build/lib/docutils/writers/__init__.py", line 80, in write
self.translate()
File "/home/david/coding/python3.3/python-docutils/python3-python-docutils-0.10-0.2.20120730svn7490.fc18/build/lib/docutils/writers/odf_odt/__init__.py", line 548, in translate
self.visitor = self.translator_class(self.document)
File "/home/david/coding/python3.3/python-docutils/python3-python-docutils-0.10-0.2.20120730svn7490.fc18/build/lib/docutils/writers/odf_odt/__init__.py", line 822, in __init__
SubElement(root, 'office:scripts')
File "/home/david/coding/python3.3/python-docutils/python3-python-docutils-0.10-0.2.20120730svn7490.fc18/build/lib/docutils/writers/odf_odt/__init__.py", line 287, in SubElement
parent.append(el)
File "/usr/lib64/python3.3/xml/etree/ElementTree.py", line 280, in append
self._assert_is_element(element)
File "/usr/lib64/python3.3/xml/etree/ElementTree.py", line 305, in _assert_is_element
raise TypeError('expected an Element, not %s' % type(e).__name__)
TypeError: expected an Element, not _ElementInterfaceWrapper
These assertions are due to type-checking that was added in Python 3.3 to xml.etree - this was http://bugs.python.org/issue13782 ("xml.etree.ElementTree: Element.append doesn't type-check its argument").
What I think is happening is that _ElementInterfaceWrapper is a subclass of the Element class defined in xml/etree/ElementTree.py, but that file later has this code:
# Import the C accelerators
try:
# Element, SubElement, ParseError, TreeBuilder, XMLParser
from _elementtree import *
except ImportError:
pass
which happens after _ElementInterfaceWrapper has been set; hence that type-checking is expecting Element to be a _elementree.Element, rather than the pure-python Element implementation.
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/docutils/bugs/200/
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/