Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue21058

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:tempfile.NamedTemporaryFile leaks file descriptor when fdopen fails
Type:resource usageStage:
Components:Library (Lib)Versions:Python 2.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: python-dev, tholzer, vajrasky, vstinner
Priority:normalKeywords:patch

Created on2014-03-25 04:47 bytholzer, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
fix_typo_21058.patchvajrasky,2014-03-25 15:15review
Messages (7)
msg214778 -(view)Author: (tholzer)Date: 2014-03-25 04:47
The NamedTemporaryFile inside the standard tempfile library leaks an open file descriptor when fdopen fails.Test case:# ulimit -SHn 50# python test1.pyfrom tempfile import NamedTemporaryFilewhile 1:    try:        NamedTemporaryFile(mode='x')    except ValueError as ex:        passOutput:Traceback (most recent call last):  File "./a2.py", line 7, in <module>  File "/usr/lib/python2.7/tempfile.py", line 454, in NamedTemporaryFile  File "/usr/lib/python2.7/tempfile.py", line 235, in _mkstemp_innerOSError: [Errno 24] Too many open files: '/tmp/tmpI0MIEW'Error in sys.excepthook:Traceback (most recent call last):  File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 66, in apport_excepthookImportError: No module named fileutilsOriginal exception was:Traceback (most recent call last):  File "./a2.py", line 7, in <module>  File "/usr/lib/python2.7/tempfile.py", line 454, in NamedTemporaryFile  File "/usr/lib/python2.7/tempfile.py", line 235, in _mkstemp_innerOSError: [Errno 24] Too many open files: '/tmp/tmpI0MIEW'Patch:@@ -452,7 +452,11 @@         flags |= _os.O_TEMPORARY      (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)-    file = _os.fdopen(fd, mode, bufsize)+    try:+        file = _os.fdopen(fd, mode, bufsize)+    except Exception as ex:+        _os.close(fd)+        raise     return _TemporaryFileWrapper(file, name, delete)  if _os.name != 'posix' or _os.sys.platform == 'cygwin':
msg214779 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2014-03-25 08:08
New changesetf2f0eec4a556 by Victor Stinner in branch '2.7':Issue#21058: Fix a leak of file descriptor in tempfile.NamedTemporaryFile(),http://hg.python.org/cpython/rev/f2f0eec4a556
msg214780 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2014-03-25 08:11
New changeset182f08c0dd45 by Victor Stinner in branch '2.7':Issue#21058: NamedTemporaryFile() closes the FD on any error, not only Exceptionhttp://hg.python.org/cpython/rev/182f08c0dd45
msg214783 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2014-03-25 08:19
New changeset7f87c26f59ab by Victor Stinner in branch '3.4':Issue#21058: Fix a leak of file descriptor in tempfile.NamedTemporaryFile(),http://hg.python.org/cpython/rev/7f87c26f59abNew changesetb1e3035216f8 by Victor Stinner in branch 'default':(Merge 3.4) Issue#21058: Fix a leak of file descriptor inhttp://hg.python.org/cpython/rev/b1e3035216f8
msg214786 -(view)Author: STINNER Victor (vstinner)*(Python committer)Date: 2014-03-25 08:22
Thanks for the report, the issue is now fixed.
msg214830 -(view)Author: Vajrasky Kok (vajrasky)*Date: 2014-03-25 15:15
There is a typo.s/io.pen/io.open/
msg214841 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2014-03-25 17:19
New changesetaa2a05fe46ae by Victor Stinner in branch '3.4':Issue#21058: fix typo in a comment. Patch written by Vajrasky Kok.http://hg.python.org/cpython/rev/aa2a05fe46aeNew changeset4e3c76cb0e8a by Victor Stinner in branch 'default':(Merge 3.4) Issue#21058: fix typo in a comment. Patch written by Vajrasky Kok.http://hg.python.org/cpython/rev/4e3c76cb0e8a
History
DateUserActionArgs
2022-04-11 14:58:00adminsetgithub: 65257
2014-03-25 17:19:59python-devsetmessages: +msg214841
2014-03-25 15:15:05vajraskysetfiles: +fix_typo_21058.patch

nosy: +vajrasky
messages: +msg214830

keywords: +patch
2014-03-25 08:22:10vstinnersetstatus: open -> closed

nosy: +vstinner
messages: +msg214786

resolution: fixed
2014-03-25 08:19:53python-devsetmessages: +msg214783
2014-03-25 08:11:09python-devsetmessages: +msg214780
2014-03-25 08:08:38python-devsetnosy: +python-dev
messages: +msg214779
2014-03-25 04:47:27tholzercreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp