[PATCH 05 of 11] cmdutil: securely rename a to A on disk
mg at lazybytes.net
Tue Aug 11 08:10:18 CDT 2009
Simon Heimberg <simohe at besonet.ch> writes:
> Am Dienstag, den 11.08.2009, 13:41 +0200 schrieb Martin Geisler:
>> Simon Heimberg <simohe at besonet.ch> writes:
>> > def temprename(src):
>> > """renames a file to a temporary name
>> > the new name is returned"""
>> > temp = tempname.mktemp(suffix='tmpmv', dir=os.path.dirname(src))
>> > os.rename(src, temp)
>> > return temp
>> > Is there a reason why tempname.mktemp was not used?
>> Yes, it is explained in the big comment just above the tempname function
>> you moved :-)
>> Short summary: an eager antivirus program might open the file created by
>> mktemp, and thereby lock the file under Windows.
>> So please move this rather important comment too, if you move the
>> function it applies to.
> mktemp does not create anything (this is mkstemp), it does (almost)
> the same as the code in the loop does.
Ah, sorry, my bad.
> The comment belongs to the exception in rename. But I could move the
> last to lines.
> mktemp is deprecated since Python 2.3. It is still there in 3.1 and
> according to  it is unlikely that it is removed. The warning in its
> code is commented out since a long time. So maybe we can use it.
>  http://mail.python.org/pipermail/python-3000/2007-August/009938.html
It's good to know that it's still there in Python 3.1. The deprecating
of mktemp is why it wasn't used originally, as far as I remember. See
also this thread:
VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 196 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20090811/dafee354/attachment.pgp
More information about the Mercurial-devel