[issue25717] tempfile.TemporaryFile fails when dir option set to directory residing on host OS mount

Martin Panter report at bugs.python.org
Tue Nov 24 03:39:42 EST 2015


Martin Panter added the comment:

Thanks for the strace output. I think the actual error is the fstat() call a bit after that first open() call. FileNotFoundError is ENOENT:

open("/vagrant/tmpy5ioznh4", O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_CLOEXEC, 0600) = 4
unlink("/vagrant/tmpy5ioznh4")          = 0
fstat(4, 0x7ffc0b326520)                = -1 ENOENT (No such file or directory)
close(4)                                = 0
write(2, "Traceback (most recent call last"..., 35Traceback (most recent call last):

My theory is that the fstat() call at <https://hg.python.org/cpython/annotate/3.5/Modules/_io/fileio.c#l441> is failing, probably because the file entry has been removed from its directory. This call was added by revision 3b5279b5bfd1 (Issue 21679). Before this change, fstat() was called twice, but in each case an error was tolerated.

Posix does not mention fstat() returning this ENOENT error, so maybe this could be a bug with the Virtual Box or Vagrant driver for the mounted filesystem. But it might be nice to make Python more permissive if fstat() fails, like it was in 3.4.

As a workaround, you may be able to use NamedTemporaryFile, if you are happy for the file to have a name and a directory entry.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25717>
_______________________________________


More information about the Python-bugs-list mailing list