Skip to content

Instantly share code, notes, and snippets.

@natefoo
Created January 5, 2015 16:12
Show Gist options
  • Save natefoo/cb7d35e9d2805a86b9ad to your computer and use it in GitHub Desktop.
Save natefoo/cb7d35e9d2805a86b9ad to your computer and use it in GitHub Desktop.
nate@weyerbacher% python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, tempfile
>>> f = tempfile.NamedTemporaryFile()
>>> f.name
'/tmp/tmptZ3yCX'
>>> os.rename(f.name, '/tmp/foo')
>>> f.write('foo\n')
>>> f.close()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/tempfile.py", line 418, in close
self.unlink(self.name)
OSError: [Errno 2] No such file or directory: '/tmp/tmptZ3yCX'
>>> open('/tmp/foo').read()
'foo\n'
>>>
@hexylena
Copy link

hexylena commented Jan 5, 2015

FYI, the specific error on hardlinking in a vboxvfs:


vagrant@precise32:/vagrant$ touch test.txt
vagrant@precise32:/vagrant$ python
Python 2.7.3 (default, Apr 20 2012, 22:44:07) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.link('test.txt', 'tmp')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 1] Operation not permitted
>>> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment