[Numpy-discussion] Handling named temporary files in tests

David Cournapeau david@ar.media.kyoto-u.ac...
Mon Mar 9 04:47:59 CDT 2009


    While fixing several windows specific unit test failures, I
encountered some problems I am not sure how to solve. In particular, we
have a relatively common idiom as follows:

Open file securely with a visible name (using NamedTemporaryFile)
write some content into it
open the file with another open call

Of course, this does not work on windows. NamedTemporaryFile is
basically useless on this platform (windows refuses to let a process to
reopen a file opened from NamedTemporaryFile). I can see two solutions:
 - using mkstemp + re-opening the file later from the name returned by
mkstemp: AFAICT, this basically defeats the whole purpose of mkstemp
 - have our own layer to bypass mkstemp on windows, where security is
not a concern anyway, and use the proper functions on sane platforms.

Do people have an opinion on this ? Or maybe a solution to the problem
altogether ?



More information about the Numpy-discussion mailing list