Author Hans Lawrenz
Recipients Hans Lawrenz, abarry, martin.panter, serhiy.storchaka
Date 2015-11-24.17:43:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1448387036.17.0.136927579197.issue25717@psf.upfronthosting.co.za>
In-reply-to
Content
Serhiy and Emanuel, I'll paste below the surrounding code and attach the exact tempfile.py. It is the version distributed with the 3.5.0 release. If you take a look at the github repo I linked in the first comment you can also try it out for yourself if you've got vagrant and virtualbox installed. I was able to recreate the error with the provisioning compiling python and with it installing from a ppa. You can see the details in the Vagrantfile. I also had a coworker test in a nearly identical environment and he had the same result.


        (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
        try:
            _os.unlink(name)
            return _io.open(fd, mode, buffering=buffering,
                            newline=newline, encoding=encoding)
        except:
            _os.close(fd)
            raise


One final note. I decided to try this out with a windows host and the only clarity this test adds is that the problem doesn't show up there but it fails for its own reasons on all the python versions I tried. See below for reference:

Last login: Tue Nov 24 17:16:12 2015 from 10.0.2.2
vagrant@vagrant-ubuntu-trusty-64:~$ cat /vagrant/foo.py
import tempfile

with tempfile.TemporaryFile(dir="/vagrant") as tf:
tf.write("testing testing testing\n".encode('utf-8'))
print("Path 2: worked")
vagrant@vagrant-ubuntu-trusty-64:~$ python /vagrant/foo.py
Traceback (most recent call last):
  File "/vagrant/foo.py", line 4, in <module>
    with tempfile.TemporaryFile(dir="/vagrant") as tf:
  File "/usr/lib/python2.7/tempfile.py", line 495, in TemporaryFile
    _os.unlink(name)
OSError: [Errno 26] Text file busy: '/vagrant/tmpvx7Mie'
vagrant@vagrant-ubuntu-trusty-64:~$ python2.7 /vagrant/foo.py
Traceback (most recent call last):
  File "/vagrant/foo.py", line 4, in <module>
    with tempfile.TemporaryFile(dir="/vagrant") as tf:
  File "/usr/lib/python2.7/tempfile.py", line 495, in TemporaryFile
    _os.unlink(name)
OSError: [Errno 26] Text file busy: '/vagrant/tmpNXQ6Cf'
vagrant@vagrant-ubuntu-trusty-64:~$ python3.4 /vagrant/foo.py
Traceback (most recent call last):
  File "/vagrant/foo.py", line 4, in <module>
    with tempfile.TemporaryFile(dir="/vagrant") as tf:
  File "/usr/lib/python3.4/tempfile.py", line 638, in TemporaryFile
    _os.unlink(name)
OSError: [Errno 26] Text file busy: '/vagrant/tmpfwhj7ip4'
vagrant@vagrant-ubuntu-trusty-64:~$ python3.5 /vagrant/foo.py
Traceback (most recent call last):
  File "/vagrant/foo.py", line 4, in <module>
    with tempfile.TemporaryFile(dir="/vagrant") as tf:
  File "/usr/lib/python3.5/tempfile.py", line 751, in TemporaryFile
    _os.unlink(name)
OSError: [Errno 26] Text file busy: '/vagrant/tmp02s19r_a'
vagrant@vagrant-ubuntu-trusty-64:~$ python2.7 --version
Python 2.7.6
vagrant@vagrant-ubuntu-trusty-64:~$ python3.4 --version
Python 3.4.3
vagrant@vagrant-ubuntu-trusty-64:~$ python3.5 --version
Python 3.5.0
History
Date User Action Args
2015-11-24 17:43:59Hans Lawrenzsetrecipients: + Hans Lawrenz, martin.panter, serhiy.storchaka, abarry
2015-11-24 17:43:56Hans Lawrenzsetmessageid: <1448387036.17.0.136927579197.issue25717@psf.upfronthosting.co.za>
2015-11-24 17:43:56Hans Lawrenzlinkissue25717 messages
2015-11-24 17:43:55Hans Lawrenzcreate