[XML-SIG] funny behaviour with Document.createTextNode

Alexandre Fayolle Alexandre.Fayolle@logilab.fr
Tue, 5 Jun 2001 18:30:23 +0200 (CEST)


One of our fellow workers came up with an interesting bug with 4DOM's
createTextNode. The bug is obviously in his code, and not in
createTextNode, but I thought I might post this here, since it might save 
time to someone some day in the future...

from xml.dom.ext import PrettyPrint
from xml.dom.ext.reader.Sax2 import FromXml
d = FromXml('<d/>') 
company = 'logilab'
print  'I work at', company
text = 'I work at', company
t = doc.documentElement.appendChild(doc.createTextNode(text))
PrettyPrint(doc)

This will give you a nice traceback, ending with:
  File "/usr/lib/python1.5/site-packages/xml/dom/ext/Printer.py", line
262, in visitText
    text = string.strip(text) and text
TypeError: read-only character buffer, tuple


For those who have not found out what the problem is, text is actually a
tuple (because the comma won't concatenate the strings). Hence the crash.


Alexandre Fayolle
-- 
http://www.logilab.com 
Narval is the first software agent available as free software (GPL).
LOGILAB, Paris (France).