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.

Title: Non-atomic and unusual (wrong) rename behavior under OS X
Type: behavior Stage: resolved
Components: macOS Versions:
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Alex Groce, ned.deily, ronaldoussoren
Priority: normal Keywords:

Created on 2017-06-24 22:59 by Alex Groce, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit Alex Groce, 2017-06-24 22:59
Messages (6)
msg296794 - (view) Author: Alex Groce (Alex Groce) * Date: 2017-06-24 22:59
Attached file causes a failed rename, which is fine.  However, after the failed rename, the directory structure has changed (and the error reported is not very helpful).  Behavior does not match Linux or Windows behavior.

Discovered using random testing to check pyfakefs for conformance with os module, using TSTL tool.
msg296837 - (view) Author: Alex Groce (Alex Groce) * Date: 2017-06-25 21:45
Checked, and this is a problem on Python 3 as well as 2.7.
msg296852 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2017-06-26 05:52
What version of macOS did you test on?
msg296853 - (view) Author: Alex Groce (Alex Groce) * Date: 2017-06-26 06:30
Tested on latest Mac OS; mv at command line does the right thing, have not checked a C rename yet.
msg296854 - (view) Author: Alex Groce (Alex Groce) * Date: 2017-06-26 07:41
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/stat.h>

int main () {
  system("rm -rf testingdir");
  system("ls -lR testingdir");
  int res = rename("testingdir","testingdir/a/a/a");
  printf("res = %d, ERRNO = %d\n",res,errno);
  system("ls -lR testingdir");  

shows that it appears to be an OS X rename issue, not a Python problem.

Lowering # directories in the chain by 1 reverts to errno 22 and correct behavior, but it's at the OS level, not Python.
msg296855 - (view) Author: Alex Groce (Alex Groce) * Date: 2017-06-26 08:11
Looks to be OS X rename, not Python
Date User Action Args
2022-04-11 14:58:48adminsetgithub: 74934
2017-06-26 08:11:10Alex Grocesetstatus: open -> closed
resolution: not a bug
messages: + msg296855

stage: resolved
2017-06-26 07:41:38Alex Grocesetmessages: + msg296854
2017-06-26 06:30:01Alex Grocesetmessages: + msg296853
2017-06-26 05:52:28ronaldoussorensetmessages: + msg296852
2017-06-25 21:45:24Alex Grocesetversions: - Python 2.7
messages: + msg296837
title: Non-atomic and unusual (wrong) rename behavior under OS X, Python 2.7.13 -> Non-atomic and unusual (wrong) rename behavior under OS X
2017-06-24 22:59:56Alex Grocecreate