diff Python/import.c @ 79827:321414874b26 2.7

Issue #6074: Restore the long-broken support for running with read-only source files on Windows
author Nick Coghlan <ncoghlan@gmail.com>
date Fri, 19 Oct 2012 21:58:18 +1000
parents ba1c48f8b571
children 002d5f3b240d
line wrap: on
line diff
--- a/Python/import.c	Thu Oct 18 07:44:43 2012 -0400
+++ b/Python/import.c	Fri Oct 19 21:58:18 2012 +1000
@@ -910,6 +910,12 @@
     time_t mtime = srcstat->st_mtime;
 #ifdef MS_WINDOWS   /* since Windows uses different permissions  */
     mode_t mode = srcstat->st_mode & ~S_IEXEC;
+    /* Issue #6074: We ensure user write access, so we can delete it later
+     * when the source file changes. (On POSIX, this only requires write
+     * access to the directory, on Windows, we need write access to the file
+     * as well)
+     */
+    mode |= _S_IWRITE;
 #else
     mode_t mode = srcstat->st_mode & ~S_IXUSR & ~S_IXGRP & ~S_IXOTH;
 #endif