main icon indicating copy to clipboard operation
main copied to clipboard

Implement _elementtree module

Open ironpythonbot opened this issue 10 years ago • 5 comments

Not much documentation on this module. It's used by the 'xml' stdlib package.

Work Item Details

Original CodePlex Issue: Issue 21407 Status: Active Reason Closed: Unassigned Assigned to: Unassigned Reported on: Feb 25, 2009 at 7:16 PM Reported by: dfugate Updated on: Feb 22, 2013 at 2:13 AM Updated by: rivimey

ironpythonbot avatar Dec 09 '14 17:12 ironpythonbot

On 2010-11-12 01:21:46 UTC, pekkaklarck commented:

IronPython 2.6.1 already has some code under xml.etree. Unfortunately even this fails:

IronPython 2.6.1 (2.6.10920.0) on .NET 4.0.30319.1 Type "help", "copyright", "credits" or "license" for more information.

from StringIO import StringIO from xml.etree import ElementTree as ET ET.parse(StringIO('')) Traceback (most recent call last): File "", line 1, in File "C:\Program Files\IronPython 2.6 for .NET 4.0\Lib\xml\etree\ElementTree.py", line 862, in parse File "C:\Program Files\IronPython 2.6 for .NET 4.0\Lib\xml\etree\ElementTree.py", line 581, in parse File "C:\Program Files\IronPython 2.6 for .NET 4.0\Lib\xml\etree\ElementTree.py", line 1117, in init ImportError: No module named expat; use SimpleXMLTreeBuilder instead

It seems SimpleXMLTreeBuilder is not included in xml.etree so basically using the provided ElementTree implementation isn't possible. I just tested that elementtree 1.2.7 preview release [1], which should have better IronPython support than 1.2.6, works well in my project. Does something prevent including it into IronPython?

[1] http://effbot.org/downloads/#elementtree

ironpythonbot avatar Dec 09 '14 17:12 ironpythonbot

On 2010-12-16 17:01:06 UTC, af001 commented:

The elementtree module is a core component for xml handling in python. It is essential for it to work!

Seo Sanghyeon appears to have written pyexpat/ElementTree for IronPython (a pyexpat emulation for IronPython which lets you use the standard ElementTree module on that platform). At least this should be included into the distribution.

The current ironpython distribution (2.6.1) has the unfortunate approach of providing a module for input that breaks immediately.

ironpythonbot avatar Dec 09 '14 17:12 ironpythonbot

On 2011-10-10 21:14:19 UTC, pekkaklarck commented:

I'm surprised this issue is considered low priority because not having a working ElementTree implementation in IronPython is a big blocker for many Python programs. I know this is an open source project with limited resources but in this case there already is a working implementation that ought to be easy to take into use (see my nearly a year old comment above about ET 1.2.7).

What's worse than not having ET is having an implementation that can be imported but not used. This means that even if you install a working ET, any code that uses the "standard" way to conditionally import ET (see e.g. http://lxml.de/tutorial.html) still doesn't work because you end up getting a broken ET implementation anyway.

ironpythonbot avatar Dec 09 '14 17:12 ironpythonbot

On 2011-10-11 23:51:13 UTC, jdhardy commented:

This issue is low priority because it refers to the _elementtree C accelerator module. To make ET work, IronPython needs a pyexpat implmentation ([workitem:20023]) or, as you pointed last year (sorry!), an upgrade to ET.

ironpythonbot avatar Dec 09 '14 17:12 ironpythonbot

On 2011-10-12 03:28:31 UTC, pekkaklarck commented:

Submitted issue #31579 about changing ET implementation to IPY compatible version.

ironpythonbot avatar Dec 09 '14 17:12 ironpythonbot