diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-02 18:00:13 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-02 18:00:13 (GMT) |
commit | 61de087f0f838f5b69592827d3d592c06aa9b655 (patch) | |
tree | 302f1a8799a529de0213a395e30fb4705b53f6bf /Lib/xml/sax/expatreader.py | |
parent | 278ba2690c9367d36f138c880130aa1390fbaa19 (diff) | |
download | cpython-61de087f0f838f5b69592827d3d592c06aa9b655.zip cpython-61de087f0f838f5b69592827d3d592c06aa9b655.tar.gz cpython-61de087f0f838f5b69592827d3d592c06aa9b655.tar.bz2 |
Issue #2175: SAX parsers now support a character stream of InputSource object.
Diffstat (limited to 'Lib/xml/sax/expatreader.py')
-rw-r--r-- | Lib/xml/sax/expatreader.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/xml/sax/expatreader.py b/Lib/xml/sax/expatreader.py index a227cda..65ac7e3 100644 --- a/Lib/xml/sax/expatreader.py +++ b/Lib/xml/sax/expatreader.py @@ -219,9 +219,14 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): self._parsing = 0 # break cycle created by expat handlers pointing to our methods self._parser = None - 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 = \ |