[XML-SIG] xml.dom.minidom.Document.createTextNode does not accept str subclasses

Rodrigo B. de Oliveira rodrigobamboo@terra.com.br
13 Jan 2003 13:24:55 -0200


The way CharacterData checks for the stringness of the data argument
does not allow str subclasses.

I figured that the reason the code is testing for type equality instead
of type compatibility (isinstance) is probably compatibility with python
versions were isinstance was not available. Is that correct?

If so, how about having something like this?

<snip>
try:
    isinstance
    def _isString(data):
        return isinstance(data, _StringTypes)# is this 2.2 only?
except NameError:
    def _isString(data):
        return type(data) in _StringTypes

class CharacterData(Node):
    def __init__(self, data):
        if not _isString(data):
            raise TypeError, "node contents must be a string"
</snip>

Any thoughts?

I will submit a patch later...
Rodrigo