Hans Lawrenz added the comment:

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

----------
Added file: http://bugs.python.org/file41153/tempfile.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25717>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to