[issue4265] shutil.copyfile() leaks file descriptors when disk fills

2010-05-05 Thread Tres Seaver
Tres Seaver tsea...@agendaless.com added the comment: I would be glad to write those tests, if you could explain the strategy you have in mind more fully: since 'shutil.copyfile' performs the 'open' itself, I couldn't figure out how to stub in such a mocked up file. Does 'open' provide a

[issue4265] shutil.copyfile() leaks file descriptors when disk fills

2010-05-05 Thread Ammon Riley
Ammon Riley ammon.ri...@gmail.com added the comment: You can replace the built-in open(), with one of your own devising: import shutil def open(*a, **k): ... raise IOError(faked error.) ... __builtins__.open = open shutil.copyfile(snake, egg) Traceback (most

[issue4265] shutil.copyfile() leaks file descriptors when disk fills

2010-05-05 Thread Tres Seaver
Tres Seaver tsea...@agendaless.com added the comment: This patch adds tests for the four edge cases (opening source fails, opening dest fails, closing dest fails, closing source fails). -- Added file: http://bugs.python.org/file17229/issue4265-test_copyfile_exceptions.patch

[issue4265] shutil.copyfile() leaks file descriptors when disk fills

2010-05-05 Thread Tarek Ziadé
Tarek Ziadé ziade.ta...@gmail.com added the comment: committed in r80830, r80831, r80833 and r80835 Thanks all ! -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org

[issue4265] shutil.copyfile() leaks file descriptors when disk fills

2010-05-05 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Wow, nice trick (shutil.open = func) :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4265 ___

[issue4265] shutil.copyfile() leaks file descriptors when disk fills

2010-05-04 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4265 ___ ___

[issue4265] shutil.copyfile() leaks file descriptors when disk fills

2010-05-04 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Could you write a test? Use a fake file objects that raise (or not) an IOError on close(), and then check that close() was closed on both files. There are 4 cases: input.close() raises or not an exception, output.close() raises or

[issue4265] shutil.copyfile() leaks file descriptors when disk fills

2010-05-02 Thread Tres Seaver
Tres Seaver tsea...@agendaless.com added the comment: This bug exists on Python 2.6, too. It seems to me that the right solution here is to use both opened files as context managers. See attached patch (made against the release26-maint branch). The patch also cleans up the old-style

[issue4265] shutil.copyfile() leaks file descriptors when disk fills

2010-05-02 Thread Tres Seaver
Changes by Tres Seaver tsea...@agendaless.com: -- versions: +Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4265 ___ ___

[issue4265] shutil.copyfile() leaks file descriptors when disk fills

2010-05-02 Thread Tres Seaver
Tres Seaver tsea...@agendaless.com added the comment: The patch doesn't apply cleanly to trunk. Attached is one which does. -- Added file: http://bugs.python.org/file17186/issue4265_shutil_copyfile-trunk.patch ___ Python tracker

[issue4265] shutil.copyfile() leaks file descriptors when disk fills

2010-05-02 Thread Tarek Ziadé
Changes by Tarek Ziadé ziade.ta...@gmail.com: -- assignee: - tarek nosy: +tarek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4265 ___ ___

[issue4265] shutil.copyfile() leaks file descriptors when disk fills

2008-12-27 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +pitrou priority: - normal stage: - patch review versions: +Python 2.7, Python 3.1 -Python 2.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4265

[issue4265] shutil.copyfile() leaks file descriptors when disk fills

2008-11-05 Thread Ammon Riley
New submission from Ammon Riley [EMAIL PROTECTED]: If the disk fills up during the copy operation, shutil.copyfile() leaks file descriptors. The problem is the order of the close() statements in the finally block. In the event the copy operation runs out of disk space, the fdst.close() call