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.

Author kyle.roberts
Recipients kyle.roberts, ncoghlan, pitrou
Date 2013-04-17.03:54:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1366170895.73.0.342235345194.issue17673@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-04-17 03:54:56kyle.robertssetrecipients: + kyle.roberts, ncoghlan, pitrou
2013-04-17 03:54:55kyle.robertssetmessageid: <1366170895.73.0.342235345194.issue17673@psf.upfronthosting.co.za>
2013-04-17 03:54:55kyle.robertslinkissue17673 messages
2013-04-17 03:54:55kyle.robertscreate