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 fd leak in fileio.c and test resource warnings
Type: resource usage Stage: resolved
Components: IO Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, bbrazil, benjamin.peterson, pitrou
Priority: normal Keywords: patch

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

Files
File name Uploaded Description Edit
fileio_fd_leak.patch bbrazil, 2010-10-30 14:59
fileio_fd_leak_v2.patch bbrazil, 2010-10-30 15:28
Messages (4)
msg119992 - (view) Author: Brian Brazil (bbrazil) * Date: 2010-10-30 14:59
fileio_init will leak a fd if you open a file for append that isn't seekable. We should close this fd before returning the failure.

The attached patch fixes this and a resource warning in the tests, but I'm unsure if it'd be better to use internal_close. I'd want the error from the seek rather than any potential error from the close, so I think this is okay.

Regrtest is happy.
msg119993 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-30 15:06
It should be closed only if closefd is true.
Does it fix a warning in the test suite? Otherwise I think it would need its own test.
msg119994 - (view) Author: Brian Brazil (bbrazil) * Date: 2010-10-30 15:28
Version 2 of the patch is attached.

This fixes a warning at line 256 in test_fileio.py:
    f = _FileIO("/dev/tty", "a")
on my Hardy machine.
msg119999 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-30 16:19
Committed in r85982, thank you. I will backport later.
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54462
2010-10-30 16:19:36pitrousetstatus: open -> closed
resolution: fixed
messages: + msg119999

stage: patch review -> resolved
2010-10-30 15:28:06bbrazilsetfiles: + fileio_fd_leak_v2.patch

messages: + msg119994
2010-10-30 15:06:55pitrousetnosy: + pitrou
messages: + msg119993
2010-10-30 15:02:57pitrousetnosy: + amaury.forgeotdarc, benjamin.peterson
stage: patch review
type: resource usage

versions: + Python 3.1, Python 2.7, Python 3.2, - Python 3.3
2010-10-30 14:59:06bbrazilcreate