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 vstinner
Recipients paul.moore, stephan, steve.dower, tim.golden, vstinner, zach.ware
Date 2016-10-04.13:50:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1475589031.37.0.948781659319.issue28356@psf.upfronthosting.co.za>
In-reply-to
Content
On Python 3 on Windows, os.rename() is implemented as MoveFileExW() with flags=0.

The doc says: "When moving a file, the destination can be on a different file system or volume. If the destination is on another drive, you must set the MOVEFILE_COPY_ALLOWED flag in dwFlags."

https://msdn.microsoft.com/en-us/library/windows/desktop/aa365240%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

I guess that the portable fix is to try rename() or fall back on copy(src, dst) + delete(src).

--

On Python 2 on Windows, os.rename() is implemented as MoveFileW(). It seems like this function behaves as MoveFileEx() called with MOVEFILE_COPY_ALLOWED:

"A new file may be on a different file system or drive."
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365239(v=vs.85).aspx

--

Should we add a flag to os.rename() to allow copy, to have a portable API?
History
Date User Action Args
2016-10-04 13:50:31vstinnersetrecipients: + vstinner, paul.moore, tim.golden, zach.ware, steve.dower, stephan
2016-10-04 13:50:31vstinnersetmessageid: <1475589031.37.0.948781659319.issue28356@psf.upfronthosting.co.za>
2016-10-04 13:50:31vstinnerlinkissue28356 messages
2016-10-04 13:50:30vstinnercreate