Comment 2 for bug 804548

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

As a side note, os.rename() doesn't work accross devices, so if /tmp happens to be on a different partition, something common in certain server installations, the operation would fail.

    def _handle_sources(self, ignored, sources):
        """Handle sources repositories."""
        fd, path = tempfile.mkstemp()
(...)
        os.rename(path, self.SOURCES_LIST)

Example:
>>> import os,tempfile
>>> fd,path = tempfile.mkstemp()
>>> os.close(fd)
>>> path
'/tmp/tmp57KbcG'
>>> os.rename(path,"/home/andreas/foo")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 18] Invalid cross-device link
>>>

From the docs at http://docs.python.org/library/os.html?highlight=os.rename#os.rename:
"The operation may fail on some Unix flavors if src and dst are on different filesystems"