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
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
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
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
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
___
Changes by STINNER Victor victor.stin...@haypocalc.com:
--
nosy: +haypo
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4265
___
___
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
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
Changes by Tres Seaver tsea...@agendaless.com:
--
versions: +Python 2.6
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4265
___
___
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
Changes by Tarek Ziadé ziade.ta...@gmail.com:
--
assignee: - tarek
nosy: +tarek
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4265
___
___
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
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
13 matches
Mail list logo