mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #14168: Check for presence of _attrs before accessing it.
This commit is contained in:
parent
f1c42599ba
commit
67245a6ed4
3 changed files with 18 additions and 3 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue