Author Unode
Recipients Unode
Date 2016-04-17.16:58:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Hi everyone,

I'm not really sure if this is a new issue but digging through the bug reports from the past I couldn't find an answer.
There's but this seems to be a different issue.
I also found that addressed problems with symlinks but didn't correct the behavior reported here.

The problem can be visualized with the following code.
Code fails on python 2.7 as well as python 3.4+. Not tested in python <2.7 and <3.4.

    import shutil
    import os
    TMPDIR = "/tmp/tmpdir"
    TESTLINK = "test_dir"
    if not os.path.isdir(TMPDIR):
    if not os.path.islink(TESTLINK):
        os.symlink(TMPDIR, TESTLINK)
    shutil.move(TESTLINK, TMPDIR)

When executed it gives me:

    % python3
    Traceback (most recent call last):
      File "", line 14, in <module>
        shutil.move(TESTLINK, TMPDIR)
      File "/usr/lib64/python3.4/", line 516, in move
        os.rename(src, dst)
    OSError: [Errno 18] Invalid cross-device link: 'test_dir' -> '/tmp/tmpdir'

This happens because /tmp is:

  tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,nodiratime)

In the past the recommendation to handle this problem was to stop using os.rename and use shutil.move instead.
This was even discussed in a bug report -

If one searches for this exception there's plenty of advice [1][2][3][4] in the same direction.
However, given that shutil.move uses os.rename internally, the problem returns.

On the other end doing the equivalent action in the shell with 'mv' works fine.

[1] -
[2] -
[3] -
[4] -
Date User Action Args
2016-04-17 16:58:17Unodesetrecipients: + Unode
2016-04-17 16:58:17Unodesetmessageid: <>
2016-04-17 16:58:17Unodelinkissue26791 messages
2016-04-17 16:58:16Unodecreate