]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-30264: ExpatParser closes the source on error (#1451)
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 5 May 2017 07:46:47 +0000 (09:46 +0200)
committerGitHub <noreply@github.com>
Fri, 5 May 2017 07:46:47 +0000 (09:46 +0200)
commitef9c0e732fc50aefbdd7c5a80e04e14b31684e66
treea59653d14c060ab0037012529ccc678ee8049b96
parent7186cc29be352bed6f1110873283d073fd0643e4
bpo-30264: ExpatParser closes the source on error (#1451)

ExpatParser.parse() of xml.sax.xmlreader now always closes the
source: close the file object or the urllib object if source is a
string (not an open file-like object). The change fixes a
ResourceWarning on parsing error.

Add test_parse_close_source() unit test.
Lib/test/test_sax.py
Lib/xml/sax/expatreader.py