From: SourceForge.net <no...@so...> - 2012-11-05 10:26:51
|
Bugs item #3555164, was opened at 2012-08-07 12:32 Message generated for change (Comment added) made by jakub-wilk You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=422030&aid=3555164&group_id=38414 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: David Malcolm () Assigned to: Nobody/Anonymous (nobody) Summary: odf writer fails when run with Python3.3b1 Initial Comment: 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. ---------------------------------------------------------------------- Comment By: Jakub Wilk (jakub-wilk) Date: 2012-11-05 02:26 Message: Oh, I just realized that the traceback is slightly different (though exception message is the same): | ====================================================================== | ERROR: test_odt_basic (test_writers.test_odt.DocutilsOdtTestCase) | ---------------------------------------------------------------------- | Traceback (most recent call last): | File "/build/python-docutils-4yaKmK/python-docutils-0.9.1/test3/test_writers/test_odt.py", line 152, in test_odt_basic | self.process_test('odt_basic.txt', 'odt_basic.odt', | File "/build/python-docutils-4yaKmK/python-docutils-0.9.1/test3/test_writers/test_odt.py", line 105, in process_test | settings_overrides=settings_overrides) | File "/build/python-docutils-4yaKmK/python-docutils-0.9.1/build/py3/docutils/core.py", line 418, in publish_string | enable_exit_status=enable_exit_status) | File "/build/python-docutils-4yaKmK/python-docutils-0.9.1/build/py3/docutils/core.py", line 666, in publish_programmatically | output = pub.publish(enable_exit_status=enable_exit_status) | File "/build/python-docutils-4yaKmK/python-docutils-0.9.1/build/py3/docutils/core.py", line 223, in publish | output = self.writer.write(self.document, self.destination) | File "/build/python-docutils-4yaKmK/python-docutils-0.9.1/build/py3/docutils/writers/__init__.py", line 80, in write | self.translate() | File "/build/python-docutils-4yaKmK/python-docutils-0.9.1/build/py3/docutils/writers/odf_odt/__init__.py", line 552, in translate | self.assemble_my_parts() | File "/build/python-docutils-4yaKmK/python-docutils-0.9.1/build/py3/docutils/writers/odf_odt/__init__.py", line 569, in assemble_my_parts | s1 = self.get_stylesheet() | File "/build/python-docutils-4yaKmK/python-docutils-0.9.1/build/py3/docutils/writers/odf_odt/__init__.py", line 616, in get_stylesheet | s1 = self.visitor.setup_page() | File "/build/python-docutils-4yaKmK/python-docutils-0.9.1/build/py3/docutils/writers/odf_odt/__init__.py", line 968, in setup_page | self.add_header_footer(self.dom_stylesheet) | File "/build/python-docutils-4yaKmK/python-docutils-0.9.1/build/py3/docutils/writers/odf_odt/__init__.py", line 1027, in add_header_footer | nsdict=STYLES_NAMESPACE_DICT, | File "/build/python-docutils-4yaKmK/python-docutils-0.9.1/build/py3/docutils/writers/odf_odt/__init__.py", line 287, in SubElement | parent.append(el) | TypeError: must be Element, not _ElementInterfaceWrapper So it's C code raising the exception, not Python code. ---------------------------------------------------------------------- Comment By: Dmitry Shachnev (mandriver) Date: 2012-11-05 02:04 Message: Ah, you are right. But now I don't understand why that fails: Python 3.3.0 (default, Oct 21 2012, 20:31:18) [GCC 4.7.2] on linux ... >>> issubclass(docutils.writers.odf_odt._ElementInterfaceWrapper, xml.etree.ElementTree.Element) False >>> issubclass(docutils.writers.odf_odt._ElementInterfaceWrapper, xml.etree.ElementTree._Element) True >>> isinstance(docutils.writers.odf_odt._ElementInterfaceWrapper(tag='mytag', attrib={}), xml.etree.ElementTree._Element) True ---------------------------------------------------------------------- Comment By: Jakub Wilk (jakub-wilk) Date: 2012-11-05 01:50 Message: This in unpatched source. Look at /usr/lib/python3.3/xml/etree/ElementTree.py, which has: if not isinstance(e, _Element): ---------------------------------------------------------------------- Comment By: Dmitry Shachnev (mandriver) Date: 2012-11-05 01:38 Message: I don't think it's backported: http://bazaar.launchpad.net/~ubuntu-branches/debian/experimental/python3.3/experimental/view/head:/Lib/xml/etree/ElementTree.py#L306 By the way, there're more python3.3 issues, I reported that as https://sourceforge.net/tracker/?func=detail&atid=422030&aid=3582720&group_id=38414. ---------------------------------------------------------------------- Comment By: Jakub Wilk (jakub-wilk) Date: 2012-11-05 01:31 Message: Debian's python3.3_3.3.0-2 has 7bd9626d8b4f backported, but I can still see this failure. ---------------------------------------------------------------------- Comment By: Dmitry Shachnev (mandriver) Date: 2012-11-02 07:17 Message: This should be now fixed with http://hg.python.org/cpython/rev/7bd9626d8b4f. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=422030&aid=3555164&group_id=38414 |