diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py index 258e138b045..e79e1044248 100644 --- a/Lib/distutils/cygwinccompiler.py +++ b/Lib/distutils/cygwinccompiler.py @@ -75,6 +75,18 @@ def get_msvcr(): elif msc_ver == '1500': # VS2008 / MSVC 9.0 return ['msvcr90'] + elif msc_ver == '1600': + # VS2010 / MSVC 10.0 + return ['msvcr100'] + elif msc_ver == '1700': + # VS2012 / MSVC 11.0 + return ['msvcr110'] + elif msc_ver == '1800': + # VS2013 / MSVC 12.0 + return ['msvcr120'] + elif msc_ver == '1900': + # VS2015 / MSVC 14.0 + return ['vcruntime140'] else: raise ValueError("Unknown MS Compiler version %s " % msc_ver) diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py index 33d3e516e9d..8df18f352e9 100644 --- a/Lib/distutils/msvc9compiler.py +++ b/Lib/distutils/msvc9compiler.py @@ -183,6 +183,10 @@ def get_build_version(): s, rest = sys.version[i:].split(" ", 1) majorVersion = int(s[:-2]) - 6 minorVersion = int(s[2:3]) / 10.0 + + # There is no majorVersion of 13 (VS2013 == 1800, and VS2015 == 1900) + if majorVersion == 13: majorVersion = 14 + # I don't think paths are affected by minor version in version 6 if majorVersion == 6: minorVersion = 0 diff --git a/Lib/distutils/msvccompiler.py b/Lib/distutils/msvccompiler.py index 0e69fd368ca..dc38f382ffa 100644 --- a/Lib/distutils/msvccompiler.py +++ b/Lib/distutils/msvccompiler.py @@ -165,6 +165,10 @@ def get_build_version(): s, rest = sys.version[i:].split(" ", 1) majorVersion = int(s[:-2]) - 6 minorVersion = int(s[2:3]) / 10.0 + + # There is no majorVersion of 13 (VS2013 == 1800, and VS2015 == 1900) + if majorVersion == 13: majorVersion = 14 + # I don't think paths are affected by minor version in version 6 if majorVersion == 6: minorVersion = 0 diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index bbb76e605f6..7d1c5a8897a 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -27,7 +27,9 @@ #include "Python.h" #include "structseq.h" -#ifndef MS_WINDOWS +#ifdef MS_WINDOWS +#include +#else #include "posixmodule.h" #endif @@ -282,6 +284,14 @@ extern int lstat(const char *, struct stat *); #define pclose _pclose #endif /* _MSC_VER */ +#if !defined(SEP) + #ifdef MS_WINDOWS + #define SEP "\\" + #else + #define SEP "/" + #endif +#endif + #if defined(PYCC_VACPP) && defined(PYOS_OS2) #include #endif /* OS2 */ @@ -533,8 +543,48 @@ _PyInt_FromDev(PY_LONG_LONG v) # define _PyInt_FromDev PyInt_FromLong #endif +#if defined _MSC_VER && _MSC_VER >= 1700 +void +_PyInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved) +{ +} + +int +_PyVerify_fd(int fd) +{ + HANDLE hFd; + _invalid_parameter_handler oldHandler; + + oldHandler = _set_invalid_parameter_handler(_PyInvalidParameterHandler); -#if defined _MSC_VER && _MSC_VER >= 1400 + hFd = _get_osfhandle(fd); + if (hFd == INVALID_HANDLE_VALUE) + goto fail; + if ((fd < 0) || _isatty(fd)) + goto fail; + + // FIXME: ensure that file descriptor is open too + _set_invalid_parameter_handler(oldHandler); + return 1; + +fail: + _set_invalid_parameter_handler(oldHandler); + return 0; +} + +static int +_PyVerify_fd_dup2(int fd1, int fd2) +{ + _invalid_parameter_handler oldHandler; + + if (!_PyVerify_fd(fd1)) + return 0; + if (fd2 < 0) + return 0; + return 1; +} + +#elif defined _MSC_VER && _MSC_VER >= 1400 /* Microsoft CRT in VS2005 and higher will verify that a filehandle is * valid and raise an assertion if it isn't. * Normally, an invalid fd is likely to be a C program error and therefore @@ -5377,6 +5427,10 @@ win32_popen4(PyObject *self, PyObject *args) return f; } +#if !defined(SEP) +#define SEP "\\" +#endif + static BOOL _PyPopenCreateProcess(char *cmdstring, HANDLE hStdin, diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 61b8d612a4a..36cbdbc9337 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -160,6 +160,10 @@ time_clock(PyObject *self, PyObject *unused) #endif /* HAVE_CLOCK */ #if defined(MS_WINDOWS) && !defined(__BORLANDC__) +#include +#define timezone _timezone +#define daylight _daylight +#define tzname _tzname /* Due to Mark Hammond and Tim Peters */ static PyObject * time_clock(PyObject *self, PyObject *unused)