]> granicus.if.org Git - python/commit
bpo-30264: ExpatParser closes the source on error (#1451) (#1475)
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 5 May 2017 08:08:05 +0000 (10:08 +0200)
committerGitHub <noreply@github.com>
Fri, 5 May 2017 08:08:05 +0000 (10:08 +0200)
commit0c9aa6ffd318c04ce23997b4704477d4a4d82829
treed36f8cfa74db434bb0528217f8ab828ed11f390a
parentee2294860e224c2b08cc6847d3c9a0ec3875c3d8
bpo-30264: ExpatParser closes the source on error (#1451) (#1475)

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.
(cherry picked from commit ef9c0e732fc50aefbdd7c5a80e04e14b31684e66)
Lib/test/test_sax.py
Lib/xml/sax/expatreader.py