Author vstinner
Recipients vstinner
Date 2019-06-26.22:39:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561588758.0.0.133123257973.issue37421@roundup.psfhosted.org>
In-reply-to
Content
Test leaking a temporary file in test_urllib:
test.test_urllib.urlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthook

I'm not sure of my fix:

diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index f6ce9cb6d5..fdddd6e2d8 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -283,6 +283,7 @@ def urlretrieve(url, filename=None, reporthook=None, data=None):
                     reporthook(blocknum, bs, size)
 
     if size >= 0 and read < size:
+        urlcleanup()
         raise ContentTooShortError(
             "retrieval incomplete: got only %i out of %i bytes"
             % (read, size), result)
History
Date User Action Args
2019-06-26 22:39:18vstinnersetrecipients: + vstinner
2019-06-26 22:39:18vstinnersetmessageid: <1561588758.0.0.133123257973.issue37421@roundup.psfhosted.org>
2019-06-26 22:39:17vstinnerlinkissue37421 messages
2019-06-26 22:39:17vstinnercreate