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 Laurent.Mazuel
Recipients Laurent.Mazuel, paul.moore, steve.dower, tim.golden, zach.ware
Date 2017-03-13.21:03:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1489439024.83.0.354569832809.issue29805@psf.upfronthosting.co.za>
In-reply-to
Content
Trying to use Pathlib and Path.replace on Windows if drive are different leads to an issue:

  File "D:\myscript.py", line 184, in update
    client_generated_path.replace(destination_folder)
  File "c:\program files (x86)\python35-32\Lib\pathlib.py", line 1273, in replace
    self._accessor.replace(self, target)
  File "c:\program files (x86)\python35-32\Lib\pathlib.py", line 377, in wrapped
    return strfunc(str(pathobjA), str(pathobjB), *args)
OSError: [WinError 17] The system cannot move the file to a different disk drive: 'C:\\MyFolder' -> 'D:\\MyFolderNewName'

This is a known situation of os.rename, and workaround I found is to use shutil or to copy/delete manually in two steps (e.g. http://stackoverflow.com/questions/21116510/python-oserror-winerror-17-the-system-cannot-move-the-file-to-a-different-d)

When using Pathlib, it's not that easy to workaround using shutil (even if thanks to Brett Cannon now shutil accepts Path in Py3.6, not everybody has Py3.6). At least this should be documented with a recommendation for that situation. I love Pathlib and it's too bad my code becomes complicated when it was so simple :(
History
Date User Action Args
2017-03-13 21:03:44Laurent.Mazuelsetrecipients: + Laurent.Mazuel, paul.moore, tim.golden, zach.ware, steve.dower
2017-03-13 21:03:44Laurent.Mazuelsetmessageid: <1489439024.83.0.354569832809.issue29805@psf.upfronthosting.co.za>
2017-03-13 21:03:44Laurent.Mazuellinkissue29805 messages
2017-03-13 21:03:44Laurent.Mazuelcreate