From: Serhiy Storchaka Date: Wed, 6 May 2015 06:38:22 +0000 (+0300) Subject: Issue #24125: Saved error's line and column numbers when an error is occured X-Git-Tag: v3.5.0b1~237 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9749b5a6a36859518c2136e3050a01008b2478eb;p=thirdparty%2FPython%2Fcpython.git Issue #24125: Saved error's line and column numbers when an error is occured during closing expatreader. Fixed a regression introduced in issue #23865. --- 9749b5a6a36859518c2136e3050a01008b2478eb diff --cc Lib/xml/sax/expatreader.py index 1795b23af60a,3b63737457d4..98b5ca953983 --- a/Lib/xml/sax/expatreader.py +++ b/Lib/xml/sax/expatreader.py @@@ -220,15 -224,17 +224,22 @@@ class ExpatParser(xmlreader.Incremental self._parsing = 0 # break cycle created by expat handlers pointing to our methods self._parser = None + finally: + self._parsing = 0 + if self._parser is not None: + # Keep ErrorColumnNumber and ErrorLineNumber after closing. + parser = _ClosedParser() + parser.ErrorColumnNumber = self._parser.ErrorColumnNumber + parser.ErrorLineNumber = self._parser.ErrorLineNumber + self._parser = parser - bs = self._source.getByteStream() - if bs is not None: - bs.close() + try: + file = self._source.getCharacterStream() + if file is not None: + file.close() + finally: + file = self._source.getByteStream() + if file is not None: + file.close() def _reset_cont_handler(self): self._parser.ProcessingInstructionHandler = \