mirror of
https://github.com/python/cpython.git
synced 2024-11-28 04:15:11 +08:00
Merge with PyXML 1.82:
Correct various typos. Fixes #674700. Set newly created attribute via setNamedItem.
This commit is contained in:
parent
c35d199404
commit
995359cbe8
@ -16,7 +16,7 @@ Todo:
|
|||||||
|
|
||||||
import xml.dom
|
import xml.dom
|
||||||
|
|
||||||
from xml.dom import EMPTY_NAMESPACE, EMPTY_PREFIX
|
from xml.dom import EMPTY_NAMESPACE, EMPTY_PREFIX, XMLNS_NAMESPACE, domreg
|
||||||
from xml.dom.minicompat import *
|
from xml.dom.minicompat import *
|
||||||
from xml.dom.xmlbuilder import DOMImplementationLS, DocumentLS
|
from xml.dom.xmlbuilder import DOMImplementationLS, DocumentLS
|
||||||
|
|
||||||
@ -384,10 +384,10 @@ class Attr(Node):
|
|||||||
else:
|
else:
|
||||||
d[name] = value
|
d[name] = value
|
||||||
|
|
||||||
def _set_prefix(self, value):
|
def _set_prefix(self, prefix):
|
||||||
nsuri = self.namespaceURI
|
nsuri = self.namespaceURI
|
||||||
if value == "xmlns":
|
if prefix == "xmlns":
|
||||||
if self.namespaceURI and self.namespaceURI != XMLNS_NAMESPACE:
|
if nsuri and nsuri != XMLNS_NAMESPACE:
|
||||||
raise xml.dom.NamespaceErr(
|
raise xml.dom.NamespaceErr(
|
||||||
"illegal use of 'xmlns' prefix for the wrong namespace")
|
"illegal use of 'xmlns' prefix for the wrong namespace")
|
||||||
d = self.__dict__
|
d = self.__dict__
|
||||||
@ -395,7 +395,7 @@ class Attr(Node):
|
|||||||
if prefix is None:
|
if prefix is None:
|
||||||
newName = self.localName
|
newName = self.localName
|
||||||
else:
|
else:
|
||||||
newName = "%s:%s" % (value, self.localName)
|
newName = "%s:%s" % (prefix, self.localName)
|
||||||
if self.ownerElement:
|
if self.ownerElement:
|
||||||
_clear_id_cache(self.ownerElement)
|
_clear_id_cache(self.ownerElement)
|
||||||
d['nodeName'] = d['name'] = newName
|
d['nodeName'] = d['name'] = newName
|
||||||
@ -536,6 +536,7 @@ class NamedNodeMap(NewStyle, GetattrMagic):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
node = Attr(attname)
|
node = Attr(attname)
|
||||||
node.ownerDocument = self._ownerElement.ownerDocument
|
node.ownerDocument = self._ownerElement.ownerDocument
|
||||||
|
self.setNamedItem(node)
|
||||||
node.value = value
|
node.value = value
|
||||||
else:
|
else:
|
||||||
if not isinstance(value, Attr):
|
if not isinstance(value, Attr):
|
||||||
@ -1008,7 +1009,8 @@ defproperty(CharacterData, "length", doc="Length of the string data.")
|
|||||||
class Text(CharacterData):
|
class Text(CharacterData):
|
||||||
# Make sure we don't add an instance __dict__ if we don't already
|
# Make sure we don't add an instance __dict__ if we don't already
|
||||||
# have one, at least when that's possible:
|
# have one, at least when that's possible:
|
||||||
__slots__ = ()
|
# XXX this does not work, CharacterData is an old-style class
|
||||||
|
# __slots__ = ()
|
||||||
|
|
||||||
nodeType = Node.TEXT_NODE
|
nodeType = Node.TEXT_NODE
|
||||||
nodeName = "#text"
|
nodeName = "#text"
|
||||||
@ -1132,7 +1134,8 @@ class Comment(Childless, CharacterData):
|
|||||||
class CDATASection(Text):
|
class CDATASection(Text):
|
||||||
# Make sure we don't add an instance __dict__ if we don't already
|
# Make sure we don't add an instance __dict__ if we don't already
|
||||||
# have one, at least when that's possible:
|
# have one, at least when that's possible:
|
||||||
__slots__ = ()
|
# XXX this does not work, Text is an old-style class
|
||||||
|
# __slots__ = ()
|
||||||
|
|
||||||
nodeType = Node.CDATA_SECTION_NODE
|
nodeType = Node.CDATA_SECTION_NODE
|
||||||
nodeName = "#cdata-section"
|
nodeName = "#cdata-section"
|
||||||
@ -1212,7 +1215,8 @@ defproperty(ReadOnlySequentialNamedNodeMap, "length",
|
|||||||
class Identified:
|
class Identified:
|
||||||
"""Mix-in class that supports the publicId and systemId attributes."""
|
"""Mix-in class that supports the publicId and systemId attributes."""
|
||||||
|
|
||||||
__slots__ = 'publicId', 'systemId'
|
# XXX this does not work, this is an old-style class
|
||||||
|
# __slots__ = 'publicId', 'systemId'
|
||||||
|
|
||||||
def _identified_mixin_init(self, publicId, systemId):
|
def _identified_mixin_init(self, publicId, systemId):
|
||||||
self.publicId = publicId
|
self.publicId = publicId
|
||||||
|
Loading…
Reference in New Issue
Block a user