cpython: 57e2549cc9a6 (original) (raw)
Mercurial > cpython
changeset 94824:57e2549cc9a6
Issue #23451: Update pyconfig.h for Windows to require Vista headers and remove unnecessary version checks. [#23451]
Steve Dower steve.dower@microsoft.com | |
---|---|
date | Mon, 02 Mar 2015 08:01:10 -0800 |
parents | 760f222103c7 |
children | 6ccbcf1df7bd |
files | Modules/_winapi.c Modules/socketmodule.h Objects/unicodeobject.c PC/pyconfig.h Python/pytime.c Python/sysmodule.c |
diffstat | 6 files changed, 29 insertions(+), 68 deletions(-)[+] [-] Modules/_winapi.c 8 Modules/socketmodule.h 7 Objects/unicodeobject.c 19 PC/pyconfig.h 6 Python/pytime.c 49 Python/sysmodule.c 8 |
line wrap: on
line diff
--- a/Modules/_winapi.c +++ b/Modules/_winapi.c @@ -1001,6 +1001,12 @@ PyDoc_STRVAR(GetVersion_doc, \n[](#l1.4) Return the version number of the current operating system."); +/* Disable deprecation warnings about GetVersionEx as the result is
- being passed straight through to the caller, who is responsible for
- using it correctly. */ +#pragma warning(push) +#pragma warning(disable:4996) +
static PyObject winapi_GetVersion(PyObject self, PyObject* args) { @@ -1010,6 +1016,8 @@ winapi_GetVersion(PyObject* self, PyObje return PyLong_FromUnsignedLong(GetVersion()); } +#pragma warning(pop) + static PyObject * winapi_OpenProcess(PyObject *self, PyObject *args) {
--- a/Modules/socketmodule.h +++ b/Modules/socketmodule.h @@ -14,6 +14,13 @@ #else /* MS_WINDOWS */
include <winsock2.h>
+/* Windows 'supports' CMSG_LEN, but does not follow the POSIX standard
include <ws2tcpip.h>
/* VC6 is shipped with old platform headers, and does not have MSTcpIP.h
--- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -519,10 +519,6 @@ unicode_result_unchanged(PyObject unico return _PyUnicode_Copy(unicode); } -#ifdef HAVE_MBCS -static OSVERSIONINFOEX winver; -#endif - / --- Bloom Filters ----------------------------------------------------- / / stuff to implement simple "bloom filters" for Unicode characters. @@ -7112,13 +7108,7 @@ static DWORD encode_code_page_flags(UINT code_page, const char *errors) { if (code_page == CP_UTF8) {
if (winver.dwMajorVersion >= 6)[](#l3.18)
/* CP_UTF8 supports WC_ERR_INVALID_CHARS on Windows Vista[](#l3.19)
and later */[](#l3.20)
return WC_ERR_INVALID_CHARS;[](#l3.21)
else[](#l3.22)
/* CP_UTF8 only supports flags=0 on Windows older than Vista */[](#l3.23)
return 0;[](#l3.24)
} else if (code_page == CP_UTF7) { /* CP_UTF7 only supports flags=0 */return WC_ERR_INVALID_CHARS;[](#l3.25)
@@ -14976,13 +14966,6 @@ int _PyUnicode_Init(void) if (PyType_Ready(&PyFormatterIter_Type) < 0) Py_FatalError("Can't initialize formatter iter type"); -#ifdef HAVE_MBCS
- winver.dwOSVersionInfoSize = sizeof(winver);
- if (!GetVersionEx((OSVERSIONINFO*)&winver)) {
PyErr_SetFromWindowsErr(0);[](#l3.36)
return -1;[](#l3.37)
- }
--- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -156,9 +156,9 @@ WIN32 is still required for the locale m #endif /* MS_WIN64 / / set the version macros for the windows headers / -/ Python 3.4+ requires Windows XP or greater / -#define Py_WINVER 0x0501 / _WIN32_WINNT_WINXP / -#define Py_NTDDI NTDDI_WINXP +/ Python 3.5+ requires Windows Vista or greater / +#define Py_WINVER 0x0600 / _WIN32_WINNT_VISTA / +#define Py_NTDDI NTDDI_VISTA / We only set these values when building Python - we don't want to force these values on extensions, as that will affect the prototypes and
--- a/Python/pytime.c +++ b/Python/pytime.c @@ -7,10 +7,6 @@ #include <mach/mach_time.h> /* mach_absolute_time(), mach_timebase_info() */ #endif -#ifdef MS_WINDOWS -static OSVERSIONINFOEX winver; -#endif - static int pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise) { @@ -124,41 +120,11 @@ pymonotonic(_PyTime_timeval *tp, _Py_clo static _PyTime_timeval last = {0, -1}; #endif #if defined(MS_WINDOWS)
- static ULONGLONG (*GetTickCount64) (void) = NULL;
- static ULONGLONG (CALLBACK *Py_GetTickCount64)(void);
- static int has_gettickcount64 = -1; ULONGLONG result; assert(info == NULL || raise);
- if (has_gettickcount64 == -1) {
/* GetTickCount64() was added to Windows Vista */[](#l5.26)
has_gettickcount64 = (winver.dwMajorVersion >= 6);[](#l5.27)
if (has_gettickcount64) {[](#l5.28)
HINSTANCE hKernel32;[](#l5.29)
hKernel32 = GetModuleHandleW(L"KERNEL32");[](#l5.30)
*(FARPROC*)&Py_GetTickCount64 = GetProcAddress(hKernel32,[](#l5.31)
"GetTickCount64");[](#l5.32)
assert(Py_GetTickCount64 != NULL);[](#l5.33)
}[](#l5.34)
- }
- if (has_gettickcount64) {
result = Py_GetTickCount64();[](#l5.38)
- }
- else {
static DWORD last_ticks = 0;[](#l5.41)
static DWORD n_overflow = 0;[](#l5.42)
DWORD ticks;[](#l5.43)
ticks = GetTickCount();[](#l5.45)
if (ticks < last_ticks)[](#l5.46)
n_overflow++;[](#l5.47)
last_ticks = ticks;[](#l5.48)
tp->tv_sec = result / 1000; tp->tv_usec = (result % 1000) * 1000; @@ -166,10 +132,7 @@ pymonotonic(_PyTime_timeval *tp, _Py_clo if (info) { DWORD timeAdjustment, timeIncrement; BOOL isTimeAdjustmentDisabled, ok;
if (has_gettickcount64)[](#l5.61)
info->implementation = "GetTickCount64()";[](#l5.62)
else[](#l5.63)
info->implementation = "GetTickCount()";[](#l5.64)
info->implementation = "GetTickCount64()";[](#l5.65) info->monotonic = 1;[](#l5.66) ok = GetSystemTimeAdjustment(&timeAdjustment, &timeIncrement,[](#l5.67) &isTimeAdjustmentDisabled);[](#l5.68)
@@ -409,14 +372,6 @@ int { _PyTime_timeval tv; -#ifdef MS_WINDOWS
- winver.dwOSVersionInfoSize = sizeof(winver);
- if (!GetVersionEx((OSVERSIONINFO*)&winver)) {
PyErr_SetFromWindowsErr(0);[](#l5.76)
return -1;[](#l5.77)
- }
-#endif - /* ensure that the system clock works */ if (_PyTime_gettimeofday_info(&tv, NULL) < 0) return -1;
--- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -772,6 +772,12 @@ static PyStructSequence_Desc windows_ver via indexing, the rest are name only / }; +/ Disable deprecation warnings about GetVersionEx as the result is
- being passed straight through to the caller, who is responsible for
- using it correctly. */ +#pragma warning(push) +#pragma warning(disable:4996) +
static PyObject * sys_getwindowsversion(PyObject *self) { @@ -803,6 +809,8 @@ sys_getwindowsversion(PyObject self) return version; } +#pragma warning(pop) + #endif / MS_WINDOWS */ #ifdef HAVE_DLOPEN