Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 73477:a9f10c3eff69
Issue #13303: Fix bytecode file default permission.
| author | Charles-François Natali <neologix@free.fr> |
|---|---|
| date | Thu, 10 Nov 2011 19:12:29 +0100 |
| parents | 60ede940089f |
| children | b75b41237380 |
line wrap: on
line diff
--- a/Python/import.c Thu Nov 10 18:24:32 2011 +0100 +++ b/Python/import.c Thu Nov 10 19:12:29 2011 +0100 @@ -1202,12 +1202,10 @@ S_IXUSR | S_IXGRP | S_IXOTH | S_IWUSR | S_IWGRP | S_IWOTH); PyObject *dirbytes; -#endif - int fd; -#ifndef MS_WINDOWS PyObject *cpathbytes, *cpathbytes_tmp; Py_ssize_t cpathbytes_len; #endif + int fd; PyObject *dirname; Py_UCS4 *dirsep; int res, ok; @@ -1275,7 +1273,7 @@ return; } cpathbytes_len = PyBytes_GET_SIZE(cpathbytes); - cpathbytes_tmp = PyBytes_FromStringAndSize(NULL, cpathbytes_len + 6); + cpathbytes_tmp = PyBytes_FromStringAndSize(NULL, cpathbytes_len + 4); if (cpathbytes_tmp == NULL) { Py_DECREF(cpathbytes); PyErr_Clear(); @@ -1283,9 +1281,10 @@ } memcpy(PyBytes_AS_STRING(cpathbytes_tmp), PyBytes_AS_STRING(cpathbytes), cpathbytes_len); - memcpy(PyBytes_AS_STRING(cpathbytes_tmp) + cpathbytes_len, "XXXXXX", 6); - - fd = mkstemp(PyBytes_AS_STRING(cpathbytes_tmp)); + memcpy(PyBytes_AS_STRING(cpathbytes_tmp) + cpathbytes_len, ".tmp", 4); + + fd = open(PyBytes_AS_STRING(cpathbytes_tmp), + O_CREAT | O_EXCL | O_WRONLY, 0666); if (0 <= fd) fp = fdopen(fd, "wb"); else
