[Python-Dev] Ext4 data loss

Nick Coghlan ncoghlan at gmail.com
Sat Mar 14 04:09:51 CET 2009


Zvezdan Petkovic wrote:
> Of course, the above are C functions.  I don't think that Python
> programming is immune from such security considerations either.

The tempfile module exposes the same functionality (and uses mkstemp()
to create its filenames). It has also had features added over the years
to prevent automatic deletion of the temporary files, precisely so you
*can* grab them and rename them afterwards.

It actually wouldn't be a bad place to put a "create a temporary file
and rename it to <name> when closing it" helper class. Such a utility
could also include a way to request "fsync() before rename" behaviour
(off by default of course).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-Dev mailing list