File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -362,11 +362,17 @@ def testChangeAttr(self):
362362 def testGetAttrList (self ):
363363 pass
364364
365- def testGetAttrValues (self ): pass
365+ def testGetAttrValues (self ):
366+ pass
366367
367- def testGetAttrLength (self ): pass
368+ def testGetAttrLength (self ):
369+ pass
368370
369- def testGetAttribute (self ): pass
371+ def testGetAttribute (self ):
372+ dom = Document ()
373+ child = dom .appendChild (
374+ dom .createElementNS ("http://www.python.org" , "python:abc" ))
375+ self .assertEqual (child .getAttribute ('missing' ), '' )
370376
371377 def testGetAttributeNS (self ):
372378 dom = Document ()
@@ -378,6 +384,9 @@ def testGetAttributeNS(self):
378384 'http://www.python.org' )
379385 self .assertEqual (child .getAttributeNS ("http://www.w3.org" , "other" ),
380386 '' )
387+ child2 = child .appendChild (dom .createElement ('abc' ))
388+ self .assertEqual (child2 .getAttributeNS ("http://www.python.org" , "missing" ),
389+ '' )
381390
382391 def testGetAttributeNode (self ): pass
383392
Original file line number Diff line number Diff line change @@ -723,12 +723,16 @@ def unlink(self):
723723 Node .unlink (self )
724724
725725 def getAttribute (self , attname ):
726+ if self ._attrs is None :
727+ return ""
726728 try :
727729 return self ._attrs [attname ].value
728730 except KeyError :
729731 return ""
730732
731733 def getAttributeNS (self , namespaceURI , localName ):
734+ if self ._attrsNS is None :
735+ return ""
732736 try :
733737 return self ._attrsNS [(namespaceURI , localName )].value
734738 except KeyError :
Original file line number Diff line number Diff line change @@ -511,6 +511,8 @@ Core and Builtins
511511Library
512512-------
513513
514+ - Issue #14168: Check for presence of _attrs before accessing it.
515+
514516- Issue #14195: An issue that caused weakref.WeakSet instances to incorrectly
515517 return True for a WeakSet instance 'a' in both 'a < a' and 'a > a' has been
516518 fixed.
You can’t perform that action at this time.
0 commit comments