summaryrefslogtreecommitdiffstats
path: root/Lib/xml
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-05-06 06:38:22 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-05-06 06:38:22 (GMT)
commit9749b5a6a36859518c2136e3050a01008b2478eb (patch)
treeb13504474193306e7b40d9e92dc0be13a0bb7830 /Lib/xml
parent076dbd05600337057723b831bfad6f6cb1873100 (diff)
parentab914780ba6165620e3db81d11cb631de58b655a (diff)
downloadcpython-9749b5a6a36859518c2136e3050a01008b2478eb.zip
cpython-9749b5a6a36859518c2136e3050a01008b2478eb.tar.gz
cpython-9749b5a6a36859518c2136e3050a01008b2478eb.tar.bz2
Issue #24125: Saved error's line and column numbers when an error is occured
during closing expatreader. Fixed a regression introduced in issue #23865.
Diffstat (limited to 'Lib/xml')
-rw-r--r--Lib/xml/sax/expatreader.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/Lib/xml/sax/expatreader.py b/Lib/xml/sax/expatreader.py
index 1795b23..98b5ca9 100644
--- a/Lib/xml/sax/expatreader.py
+++ b/Lib/xml/sax/expatreader.py
@@ -43,6 +43,9 @@ else:
_mkproxy = weakref.proxy
del weakref, _weakref
+class _ClosedParser:
+ pass
+
# --- ExpatLocator
class ExpatLocator(xmlreader.Locator):
@@ -211,16 +214,24 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator):
self._err_handler.fatalError(exc)
def close(self):
- if self._entity_stack or self._parser is None:
+ if (self._entity_stack or self._parser is None or
+ isinstance(self._parser, _ClosedParser)):
# If we are completing an external entity, do nothing here
return
try:
self.feed("", isFinal = 1)
self._cont_handler.endDocument()
- finally:
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
try:
file = self._source.getCharacterStream()
if file is not None: