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

Hans Lawrenz report at bugs.python.org
Mon Nov 23 23:23:44 EST 2015


New submission from Hans Lawrenz:

Inside a virtualbox vm, calling tempfile.TemporaryFile(dir=foo) where foo is a directory which resides on a volume mounted from the host OS, a FileNotFoundError exception is thrown.

In the following code sample, the second block will print "Path 2: ERROR" on Python 3.5 but not on 3.4 or 2.7 (assuming the vagrant environment provided below):

import tempfile


try:
    with tempfile.TemporaryFile() as tf:
        tf.write("testing testing testing\n".encode('utf-8'))
    print("Path 1: worked")
except FileNotFoundError as e:
    print("Path 1: ERROR")

try:
    with tempfile.TemporaryFile(dir="/vagrant") as tf:
        tf.write("testing testing testing\n".encode('utf-8'))
    print("Path 2: worked")
except FileNotFoundError as e:
    print("Path 2: ERROR")


A runnable test case can be found here:
https://github.com/hlawrenz/py35tempfiletest

----------
components: Library (Lib)
messages: 255246
nosy: Hans Lawrenz
priority: normal
severity: normal
status: open
title: tempfile.TemporaryFile fails when dir option set to directory residing on host OS mount
type: behavior
versions: Python 3.5

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


More information about the New-bugs-announce mailing list