[XML-SIG] xml.dom.minidom.Document.createTextNode does not
accept str subclasses
Rodrigo B. de Oliveira
rodrigobamboo@terra.com.br
13 Jan 2003 20:03:16 -0200
Uops... Sorry, my bad.
I thought I had the latest PyXML at the office but as it turned out I
had it installed at home only.
Thanks and sorry again for the incovenience!
Rodrigo
>
> Rodrigo B. de Oliveira writes:
> > The way CharacterData checks for the stringness of the data argument
> > does not allow str subclasses.
>
> What version of PyXML are you using? For 0.8 and 0.8.1, this problem
> should be solved, but you aren't allowed to simply call the
> constructor any more; that doesn't enforce all the invariants
> directly. You'll need to call the createTextNode() method of the
> document object.
>
> > 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?
>
> The current version of the code provides a suitable isinstance() when
> needed; see the xml.dom.minicompat module for the specific code if
> you're interested.
>
> > If so, how about having something like this?
> ...
> > class CharacterData(Node):
> > def __init__(self, data):
> > if not _isString(data):
> > raise TypeError, "node contents must be a string"
>
> But, as noted above, there isn't a CharacterData.__init__() any more.
>
>
> -Fred
>
> --
> Fred L. Drake, Jr. <fdrake at acm.org>
> PythonLabs at Zope Corporation
>
> _______________________________________________
> XML-SIG maillist - XML-SIG@python.org
> http://mail.python.org/mailman/listinfo/xml-sig
>