This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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

Created on 2012-05-18 10:13 by cmn, last changed 2022-04-11 14:57 by admin. 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"
# 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'

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
Date User Action Args
2022-04-11 14:57:30adminsetnosy: + georg.brandl
github: 59054
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