[Python-checkins] CVS: python/dist/src/Lib xmllib.py,1.19,1.20
Sjoerd Mullender
python-dev@python.org
Tue, 4 Jul 2000 07:53:14 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory slayer.i.sourceforge.net:/tmp/cvs-serv15231
Modified Files:
xmllib.py
Log Message:
2 fixes plus one extension:
- Actually count the linefeeds in a the CDATA content.
- Don't call the endtag handler for an unmatched endtag (this makes
the base class simpler since it doesn't have to deal with unopened
endtags).
- If the __init__ method is called with keyword argument
translate_attribute_references=0, don't attempt to translate
character and entity references in attribute values.
Index: xmllib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/xmllib.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** xmllib.py 2000/06/28 14:48:01 1.19
--- xmllib.py 2000/07/04 14:53:12 1.20
***************
*** 91,94 ****
--- 91,95 ----
__map_case = 0
__accept_utf8 = 0
+ __translate_attribute_references = 1
# Interface -- initialize and reset this instance
***************
*** 103,106 ****
--- 104,109 ----
if kw.has_key('accept_utf8'):
self.__accept_utf8 = kw['accept_utf8']
+ if kw.has_key('translate_attribute_references'):
+ self.__translate_attribute_references = kw['translate_attribute_references']
self.reset()
***************
*** 172,175 ****
--- 175,180 ----
# Interface -- translate references
def translate_references(self, data, all = 1):
+ if not self.__translate_attribute_references:
+ return data
i = 0
while 1:
***************
*** 278,282 ****
k = self.parse_cdata(i)
if k < 0: break
! self.lineno = self.lineno + string.count(rawdata[i:i], '\n')
i = k
continue
--- 283,287 ----
k = self.parse_cdata(i)
if k < 0: break
! self.lineno = self.lineno + string.count(rawdata[i:k], '\n')
i = k
continue
***************
*** 692,700 ****
if found == -1:
self.syntax_error('unopened end tag')
- method = self.elements.get(tag, (None, None))[1]
- if method is not None:
- self.handle_endtag(tag, method)
- else:
- self.unknown_endtag(tag)
return
while len(self.stack) > found:
--- 697,700 ----