Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c793779

Browse files
Fix Issue #9752: MSVC compiler warning due to undefined function
(Patch by Jon Anglin)
1 parent 460ff3d commit c793779

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Python/import.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ extern "C" {
2525
#ifdef MS_WINDOWS
2626
/* for stat.st_mode */
2727
typedef unsigned short mode_t;
28+
/* for _mkdir */
29+
#include <direct.h>
2830
#endif
2931

3032

@@ -1134,9 +1136,6 @@ write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat)
11341136
time_t mtime = srcstat->st_mtime;
11351137
#ifdef MS_WINDOWS /* since Windows uses different permissions */
11361138
mode_t mode = srcstat->st_mode & ~S_IEXEC;
1137-
mode_t dirmode = srcstat->st_mode | S_IEXEC; /* XXX Is this correct
1138-
for Windows?
1139-
2010-04-07 BAW */
11401139
#else
11411140
mode_t mode = srcstat->st_mode & ~S_IXUSR & ~S_IXGRP & ~S_IXOTH;
11421141
mode_t dirmode = (srcstat->st_mode |
@@ -1156,8 +1155,12 @@ write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat)
11561155
}
11571156
saved = *dirpath;
11581157
*dirpath = '\0';
1159-
/* XXX call os.mkdir() or maybe CreateDirectoryA() on Windows? */
1158+
1159+
#ifdef MS_WINDOWS
1160+
if (_mkdir(cpathname) < 0 && errno != EEXIST) {
1161+
#else
11601162
if (mkdir(cpathname, dirmode) < 0 && errno != EEXIST) {
1163+
#endif
11611164
*dirpath = saved;
11621165
if (Py_VerboseFlag)
11631166
PySys_WriteStderr(

0 commit comments

Comments
 (0)