This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, fireattack, paul.moore, serhiy.storchaka, steve.dower, tim.golden, zach.ware
Date 2021-01-15.16:18:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1610727494.41.0.246930962589.issue42929@roundup.psfhosted.org>
In-reply-to
Content
I can help, but in this case there isn't much to do. Just replace os.rename() with os.replace(), make a minor doc change, and maybe add a test that ensures a junction can be moved over an existing file on the same filesystem. For example:

    >>> os.mkdir('temp')
    >>> _winapi.CreateJunction('temp', 'src')
    >>> os.lstat('src').st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT
    True
    >>> open('dst', 'w').close()

The current implementation tries copytree() on the junction mountpoint and fails to create a new directory named "dst":

    >>> try: shutil.move('src', 'dst')
    ... except FileExistsError as e: e
    ...
    FileExistsError(17, 'Cannot create a file when that file already exists')

But move() should simply replace "dst" with the junction via os.replace():

    >>> os.replace('src', 'dst')
    >>> os.lstat('dst').st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT
    True
History
Date User Action Args
2021-01-15 16:18:14eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, serhiy.storchaka, steve.dower, fireattack
2021-01-15 16:18:14eryksunsetmessageid: <1610727494.41.0.246930962589.issue42929@roundup.psfhosted.org>
2021-01-15 16:18:14eryksunlinkissue42929 messages
2021-01-15 16:18:14eryksuncreate