diff options
author | Charles-François Natali <neologix@free.fr> | 2011-11-10 18:12:29 (GMT) |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2011-11-10 18:12:29 (GMT) |
commit | 0c929d9d397c2a2578a2b016ae9b3d258ab513aa (patch) | |
tree | ffd2b8398314f5c52ecb0ce7052351bf57a82d0b /Python/import.c | |
parent | 1db7c13be1cbf29af66306b471bc826dadb8efa4 (diff) | |
download | cpython-0c929d9d397c2a2578a2b016ae9b3d258ab513aa.zip cpython-0c929d9d397c2a2578a2b016ae9b3d258ab513aa.tar.gz cpython-0c929d9d397c2a2578a2b016ae9b3d258ab513aa.tar.bz2 |
Issue #13303: Fix bytecode file default permission.
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Python/import.c b/Python/import.c index 5c33b6b..ae1101e 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1202,12 +1202,10 @@ write_compiled_module(PyCodeObject *co, PyObject *cpathname, 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 @@ write_compiled_module(PyCodeObject *co, PyObject *cpathname, 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 @@ write_compiled_module(PyCodeObject *co, PyObject *cpathname, } memcpy(PyBytes_AS_STRING(cpathbytes_tmp), PyBytes_AS_STRING(cpathbytes), cpathbytes_len); - memcpy(PyBytes_AS_STRING(cpathbytes_tmp) + cpathbytes_len, "XXXXXX", 6); + memcpy(PyBytes_AS_STRING(cpathbytes_tmp) + cpathbytes_len, ".tmp", 4); - fd = mkstemp(PyBytes_AS_STRING(cpathbytes_tmp)); + fd = open(PyBytes_AS_STRING(cpathbytes_tmp), + O_CREAT | O_EXCL | O_WRONLY, 0666); if (0 <= fd) fp = fdopen(fd, "wb"); else |