Issue #14168: Check for presence of _attrs before accessing it.

This commit is contained in:
Martin v. Löwis 2012-03-05 07:01:49 +01:00
parent f1c42599ba
commit 67245a6ed4
3 changed files with 18 additions and 3 deletions

View file

@ -723,12 +723,16 @@ class Element(Node):
Node.unlink(self)
def getAttribute(self, attname):
if self._attrs is None:
return ""
try:
return self._attrs[attname].value
except KeyError:
return ""
def getAttributeNS(self, namespaceURI, localName):
if self._attrsNS is None:
return ""
try:
return self._attrsNS[(namespaceURI, localName)].value
except KeyError: