classification
Title: C implementation of ElementTree: Inheriting from Element breaks text member
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eli.bendersky Nosy List: Arfrever, cmn, eli.bendersky, ezio.melotti, python-dev
Priority: release blocker Keywords:

Created on 2012-05-18 10:13 by cmn, last changed 2012-05-20 03:42 by eli.bendersky. This issue is now closed.

Messages (3)
msg161043 - (view) Author: Markus (cmn) * Date: 2012-05-18 10:13
Example Code to reproduce:

from xml.etree import ElementTree as etree
class xetree:
	cElement = etree.Element
	class Element(etree.Element):
		def __init__(self, tag, attrib=None):
			xetree.cElement.__init__(self, tag, attrib)

etree.Element = xetree.Element

e = etree.Element("test", {'foobar':'bar'})
e.text = "failure"
print(etree.tostring(e))
# will lack "failure"

So basic inheritance is broken.
msg161177 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2012-05-20 03:10
Here's a simpler testcase:

import xml.etree.ElementTree as ET

class XElement(ET.Element):
    def __init__(self, tag, attrib={}):
        ET.Element.__init__(self, tag, attrib)

e = XElement('test')
e.text = 'failure'

print(ET.tostring(e))
msg161178 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-05-20 03:33
New changeset 41a9d24d075e by Eli Bendersky in branch 'default':
Issue #14849: setup Element data members to be assignable in subclasses
http://hg.python.org/cpython/rev/41a9d24d075e
History
Date User Action Args
2012-05-20 03:42:38eli.benderskysetstatus: open -> closed
assignee: eli.bendersky
resolution: fixed
stage: needs patch -> resolved
2012-05-20 03:33:38python-devsetnosy: + python-dev
messages: + msg161178
2012-05-20 03:10:18eli.benderskysetmessages: + msg161177
2012-05-18 16:14:38Arfreversetnosy: + Arfrever
2012-05-18 10:14:38ezio.melottisetpriority: normal -> release blocker
nosy: + ezio.melotti, eli.bendersky

type: behavior
stage: needs patch
2012-05-18 10:13:18cmncreate