This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix resource warnings in distutils
Type: resource usage Stage: resolved
Components: Distutils Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: bbrazil, brian.curtin, eric.araujo, eric.smith, loewis, pitrou, python-dev, tarek
Priority: normal Keywords: patch

Created on 2010-10-30 14:22 by bbrazil, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
distutils_fd_leak.patch bbrazil, 2010-10-30 14:22 review
distutils_fd_leak_v2.patch bbrazil, 2010-11-02 19:29 review
fix-popen.diff eric.araujo, 2010-11-06 14:10 review
fix_pipe_close.diff brian.curtin, 2010-11-06 17:56
Messages (16)
msg119988 - (view) Author: Brian Brazil (bbrazil) * Date: 2010-10-30 14:22
Please see attached.
msg120155 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-01 19:39
Thanks for the patch, I’ll review it and commit it soon.
msg120198 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-11-02 01:01
The patch shouldn't use context managers, as distutils claims to support 2.3. #10290 contains a similar patch which doesn't use 'with'. (Sorry to duplicate efforts here, forgot to search...)
msg120249 - (view) Author: Brian Brazil (bbrazil) * Date: 2010-11-02 19:29
I don't see your patch on the other bug, so I've updated mine not to use with.
msg120561 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2010-11-05 23:59
Is it really true that 3.x's distutils is source compatible with 2.3?

For 3.x I'd like to see the with statement used.
msg120567 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-06 01:11
Fixed in the py3k branch in r86223, r86224 and r86226.  Thanks for the report and starting patch.

Eric: This compatibility policy was instated because a newer version of distutils may be used/is often used to install distributions for older Pythons.  In the 2.x line, this was enforced.  I checked the current py3k code with the oldest version I have, 2.4, and it’s not entirely compatible.  Python 3.x is developed as a clean break from 2.x (no versionchanged directives in docs, etc.), so what’s the status of the distutils compatibility policy?  I think that the reasons are still valid, so keeping 2.x source compat in py3k is a nice thing to do for our users.  Even if we’re working on distutils2 (which will have releases for 2.4-3.2), distutils is still widely used and we expect a long transition period.

I can bring this up on python-dev if you think it’s needed.
msg120569 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-06 01:39
(Not closing yet: Some calls of os.popen and subprocess.Popen are still to be fixed, and then there’s the backport.)
msg120578 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-06 04:07
[Pp]open objects closed in r86234.

All fixes ported to 3.1 in r86237, 2.7 in r86238.  Cheers!
msg120614 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-06 14:10
The tests don’t pass on a Windows buildbot (thanks Antoine): I was mistaken about subprocess.Popen, it has no close method like os.popen objects.  Attached patch should fix it, can someone kindly review and/or test it?
msg120631 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-06 15:59
Committed to py3k in r86274, after “LGTM” from Brian on IRC.  Will backport if buildbots don’t scream at me.
msg120644 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-06 18:04
Thanks for the patch.  r86276
msg121072 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-12 20:35
Ported to 3.1 and 2.7 in r86433 and r86434.
msg121085 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-12 22:39
No file object was created for stdin, so my patch was buggy.  Fixed in r86438, r86439, r86440.  Thanks to Antoine and Brian.
msg121546 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-19 16:13
These constructs don’t generate warnings at present but should IMO use the with statement too:

./distutils/command/upload.py:128:                                     open(filename+".asc").read())
./distutils/command/bdist_rpm.py:514:                    spec_file.extend(open(val, 'r').read().split('\n'))
./distutils/command/bdist_wininst.py:248:            bitmapdata = open(bitmap, "rb").read()
./distutils/command/bdist_wininst.py:288:        file.write(open(arcname, "rb").read())
./distutils/command/bdist_msi.py:399:            f.write(open(self.pre_install_script).read())
msg134567 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-04-27 14:37
New changeset 85fefd41ef5d by Éric Araujo in branch '3.2':
Fix double use of f.close().
http://hg.python.org/cpython/rev/85fefd41ef5d
msg134961 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-02 11:39
New changeset c02c78d93a2e by Éric Araujo in branch '2.7':
Fix double use of f.close().
http://hg.python.org/cpython/rev/c02c78d93a2e
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54461
2011-05-02 11:39:07python-devsetmessages: + msg134961
2011-04-27 14:37:35python-devsetnosy: + python-dev
messages: + msg134567
2010-11-19 16:13:06eric.araujosetmessages: + msg121546
2010-11-12 22:39:13eric.araujosetmessages: + msg121085
2010-11-12 20:35:42eric.araujosetstatus: open -> closed
resolution: fixed
messages: + msg121072

stage: patch review -> resolved
2010-11-06 18:04:18eric.araujosetmessages: + msg120644
2010-11-06 17:56:22brian.curtinsetfiles: + fix_pipe_close.diff
2010-11-06 15:59:54eric.araujosetmessages: + msg120631
2010-11-06 14:10:51eric.araujosetstatus: closed -> open
resolution: fixed -> (no value)
stage: resolved -> patch review
2010-11-06 14:10:27eric.araujosetfiles: + fix-popen.diff
nosy: + pitrou
messages: + msg120614

2010-11-06 04:07:40eric.araujosetstatus: open -> closed
versions: + Python 3.1, Python 2.7
messages: + msg120578

resolution: fixed
stage: patch review -> resolved
2010-11-06 01:39:21eric.araujosetmessages: + msg120569
2010-11-06 01:11:11eric.araujosetnosy: + loewis
messages: + msg120567
2010-11-05 23:59:05eric.smithsetnosy: + eric.smith
messages: + msg120561
2010-11-02 19:29:38bbrazilsetfiles: + distutils_fd_leak_v2.patch

messages: + msg120249
2010-11-02 01:01:11brian.curtinsetstatus: pending -> open
nosy: + brian.curtin
messages: + msg120198

2010-11-01 19:39:46eric.araujosetstatus: open -> pending
assignee: tarek -> eric.araujo
messages: + msg120155

title: Fix resource warnings in distutil tests -> Fix resource warnings in distutils
2010-10-30 14:25:40pitrousetstage: patch review
type: resource usage
versions: + Python 3.2, - Python 3.3
2010-10-30 14:22:52bbrazilcreate