classification
Title: Fix potential resource warnings in distutils
Type: enhancement Stage: resolved
Components: Distutils Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Tiger-222, dstufft, eric.araujo, inada.naoki, serhiy.storchaka, xtreak
Priority: normal Keywords: patch

Created on 2018-12-05 08:54 by Tiger-222, last changed 2019-04-08 13:20 by inada.naoki. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 10918 merged Tiger-222, 2018-12-05 08:59
Messages (6)
msg331097 - (view) Author: Mickaël Schoentgen (Tiger-222) * Date: 2018-12-05 08:54
I am looking to clean-up potential ResourceWarnings in distutils. The patch will provide 2 changes:
    - ensure file descriptor are always closed when it is not the case
    - and uniformization of the "with open(...)" use
msg331107 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python triager) Date: 2018-12-05 12:55
There is a similar open issue issue22831 with patches for distutils and Tools.
msg331110 - (view) Author: Mickaël Schoentgen (Tiger-222) * Date: 2018-12-05 13:10
I saw it but it is quite old and targetting 3.5. I opended this issue to target only distutils, easier to eventually backport than a big patch on a lot of files.
msg331114 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2018-12-05 14:08
I think the places that already use try/finally: close are correct.

We try to minimize churn in distutils; changing to with is nice but does not fix errors or warning in these cases.

The changes for the few spots that don’t use finally: close are welcome though!
msg331118 - (view) Author: Mickaël Schoentgen (Tiger-222) * Date: 2018-12-05 14:38
OK then I updated the PR to only update code that would really leak resources.
msg339635 - (view) Author: Inada Naoki (inada.naoki) * (Python committer) Date: 2019-04-08 13:08
New changeset 58721a903074d28151d008d8990c98fc31d1e798 by Inada Naoki (Mickaël Schoentgen) in branch 'master':
bpo-35416: fix potential resource warnings in distutils (GH-10918)
https://github.com/python/cpython/commit/58721a903074d28151d008d8990c98fc31d1e798
History
Date User Action Args
2019-04-08 13:20:52inada.naokisetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-04-08 13:08:54inada.naokisetnosy: + inada.naoki
messages: + msg339635
2018-12-05 14:38:17Tiger-222setmessages: + msg331118
2018-12-05 14:08:14eric.araujosetmessages: + msg331114
2018-12-05 13:10:06Tiger-222setmessages: + msg331110
2018-12-05 12:55:57xtreaksetnosy: + serhiy.storchaka, xtreak
messages: + msg331107
2018-12-05 08:59:35Tiger-222setkeywords: + patch
stage: patch review
pull_requests: + pull_request10157
2018-12-05 08:54:19Tiger-222create