Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1e68827

Browse files
author
Paul Prescod
committed
Misc fixes and improvements.
1 parent bd8c2ae commit 1e68827

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

Lib/xml/dom/minidom.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def __init__( self ):
4040
index=repr( id( self ))+repr( self.__class__ )
4141
Node.allnodes[index]=repr( self.__dict__ )
4242
if Node.debug==None:
43-
Node.debug=open( "debug4.out", "w" )
43+
Node.debug=StringIO()
44+
#open( "debug4.out", "w" )
4445
Node.debug.write( "create %s\n"%index )
4546

4647
def __getattr__( self, key ):
@@ -216,13 +217,24 @@ def __cmp__( self, other ):
216217

217218
#FIXME: is it appropriate to return .value?
218219
def __getitem__( self, attname_or_tuple ):
219-
if type( attname_or_tuple ) == type( () ):
220+
if type( attname_or_tuple ) == types.TupleType:
220221
return self._attrsNS[attname_or_tuple]
221222
else:
222223
return self._attrs[attname_or_tuple]
223224

224-
def __setitem__( self, attname ):
225-
raise TypeError, "object does not support item assignment"
225+
# same as set
226+
def __setitem__( self, attname, value ):
227+
if type( value ) == types.StringType:
228+
node=Attr( attname )
229+
node.value=value
230+
else:
231+
assert isinstance( value, Attr ) or type( value )==types.StringType
232+
node=value
233+
old=self._attrs.get( attname, None)
234+
if old:
235+
old.unlink()
236+
self._attrs[node.name]=node
237+
self._attrsNS[(node.namespaceURI,node.localName)]=node
226238

227239
def __delitem__( self, attname_or_tuple ):
228240
node=self[attname_or_tuple]

0 commit comments

Comments
 (0)