Kyle Roberts added the comment:

Attached is a patch to include the copy_from argument in mkstemp, 
TemporaryFile, and NamedTemporaryFile. Also attached is a text file for testing 
the copy operation.

Some notes:

I intended to use shutil's copyfile(src, dst) method to copy the copy_from file 
to the temp file, but copyfile implicitly closes the dst file (our temp file), 
which would lead to deleting the temp file. I created a simple private 
_copyfile(src, dst) that keeps the dst file open after writing to it. One 
question I have regarding my _copyfile is should I include the check for a 
named pipe as was done in shutil.copyfile? I think that the same issue applies 
as described in http://bugs.python.org/issue3002.

Another thing I wasn't sure of is the best way to include a test file. The 
copy_from tests included in the patch include a txt file, but the way I went 
about getting it seems wonky. Is there a best practice for this?

Finally, the copy_from parameter only takes a string filepath argument. I 
thought it might be better to avoid handling two different types (string or 
file-like object) for copying because that is how other copy operations (i.e. 
copyfile()) work.

----------
keywords: +patch
Added file: http://bugs.python.org/file29895/copy_from.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17673>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to