Peter Simanyi added the comment:
I verified that launching the script from a CMD.EXE window instead of
from Cygwin also reproduces the "can't overwrite ZZZ.pyc". Here's a
sample of "python -v" showing this:
# C:\depot\central\ntf\tools\bin\build1.pyc has bad
Peter Simanyi added the comment:
Re: chmod 0666 inappropriate: I agree that leaving a file 0666 is
inappropriate, however theoretically
the code should never leave the file 0666 since the unlink will delete the file.
The code was intended to show what the problem is by demonstrating a
Peter Simanyi added the comment:
I realized that my patch, with a chmod(..., 0600), may not work under
certain conditions where the original file is owned by a different user
but the directory is group- or world-writable. A more likely correct fix
would use chmod(..., 0666).
At any rate
Peter Simanyi added the comment:
I have a fix for this. The code is Windows-only. It has been verified to work
for attached test script
showpycreadonlysleep.sh. It simply adds a "chmod" call. The issue is that the
unlink() call silently fails
if the file is readonly, but unlink(
Peter Simanyi added the comment:
I may have a reason to analyze that would explain why this fails on
Windows: the non-Windows code path in import.c's open_exclusive() contians
an unlink(filename), but the Windows path does not.
I'm going to try to build Python on Windows and add
Peter Simanyi added the comment:
Re: Ubuntu: I can't reproduce the problem. At this point, I consider this
problem Windows XP-only.
Re: Windows & bash: I decided to verify that this problem occurs even if
running outside of Bash in
the native (and wonderful) shell CMD.EXE. It *do
Peter Simanyi added the comment:
Oops, I was not accurate in reporting behavior: I now believe that this fails
on Windows XP, but may work
fine on Linux. Below are my results, showing reproducible failure on XP. The
most important thing about
this is: on XP, once the .pyc file is "b
New submission from Peter Simanyi :
Some source code control tools, like Perforce, by default sync files readonly,
and it's useful to
leave them readonly so that you can mark files changed by making them writeable
even if they're not
checked out (e.g. working offline).
W