| 795 | return self._attrsNS.get((namespaceURI, localName)) |
| 796 | |
| 797 | def setAttributeNode(self, attr): |
| 798 | if attr.ownerElement not in (None, self): |
| 799 | raise xml.dom.InuseAttributeErr("attribute node already owned") |
| 800 | self._ensure_attributes() |
| 801 | old1 = self._attrs.get(attr.name, None) |
| 802 | if old1 is not None: |
| 803 | self.removeAttributeNode(old1) |
| 804 | old2 = self._attrsNS.get((attr.namespaceURI, attr.localName), None) |
| 805 | if old2 is not None and old2 is not old1: |
| 806 | self.removeAttributeNode(old2) |
| 807 | _set_attribute_node(self, attr) |
| 808 | |
| 809 | if old1 is not attr: |
| 810 | # It might have already been part of this node, in which case |
| 811 | # it doesn't represent a change, and should not be returned. |
| 812 | return old1 |
| 813 | if old2 is not attr: |
| 814 | return old2 |
| 815 | |
| 816 | setAttributeNodeNS = setAttributeNode |
| 817 | |