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 pdsimanyi
Recipients markon, pdsimanyi
Date 2009-05-26.22:17:23
SpamBayes Score 0.0
Marked as misclassified No
Message-id <1243376245.35.0.656664136236.issue6074@psf.upfronthosting.co.za>
In-reply-to
Content
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() succeeds if chmod() makes the file writable. Out company would really appreciate having this fix integrated into 2.6 since we use the ActiveState 2.6 builds on Windows. I haven't test this on non-Windows platforms but it should not change the behavior on non-Windows platforms if the #ifdef MS_WINDOWS is correct. The diff is below: $ svn diff Index: import.c =================================================================== --- import.c (revision 72946) +++ import.c (working copy) @@ -840,6 +840,7 @@ static FILE * open_exclusive(char *filename, mode_t mode) { + #if defined(O_EXCL)&&defined(O_CREAT)&&defined(O_WRONLY)&&defined(O_TRUNC) /* Use O_EXCL to avoid a race condition when another process tries to write the same file. When that happens, our open() call fails, @@ -848,6 +849,9 @@ writable, the file will never be written. Oh well. */ int fd; +#ifdef MS_WINDOWS + (void) chmod(filename, 0600); +#endif (void) unlink(filename); fd = open(filename, O_EXCL|O_CREAT|O_WRONLY|O_TRUNC #ifdef O_BINARY It may be appropriate to document that the chmod() is only required on Windows, and therefore it is only called on Windows to avoid slowing down non-Windows platforms.
History
Date User Action Args
2009-05-26 22:17:25pdsimanyisetrecipients: + pdsimanyi, markon
2009-05-26 22:17:25pdsimanyisetmessageid: <1243376245.35.0.656664136236.issue6074@psf.upfronthosting.co.za>
2009-05-26 22:17:24pdsimanyilinkissue6074 messages
2009-05-26 22:17:23pdsimanyicreate