Strange problem with xml.dom.minidom Text object (Python 2.3)

Hans Nowak hans at zephyrfalcon.org
Thu Sep 4 20:44:00 CEST 2003


[Not sure if this message made it, so I'm resending it... apologies if it 
appears multiple times.]


Howdy y'all,

The following works in Python 2.2.2:

Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> from xml.dom.minidom import Text
 >>> t = Text("foo")
 >>> t
<DOM Text node "foo">

So far, so good.  We have production code that uses the Text class by 
initializing it with a string, and it works well.  However:

(C:\work\uq\ticket_parse) $ \Python23\python.exe
Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> from xml.dom.minidom import Text
 >>> t = Text("foo")
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
TypeError: this constructor takes no arguments

So I thought, maybe this was disallowed for some reason.  What happens if we 
create the object without arguments?  It works, but when doing a __repr__, the 
object lacks the .data attribute, which is odd:

 >>> t = Text()
 >>> t
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "C:\Python23\lib\xml\dom\minidom.py", line 956, in __repr__
     data = self.data
AttributeError: Text instance has no attribute 'data'

Anybody knows what's going on here?  I didn't see this as a bug in the 
BugTracker.  Am I doing something wrong?

-- 
Hans (hans at zephyrfalcon.org)
http://zephyrfalcon.org/







More information about the Python-list mailing list