From 8fa7f24e6ca3d8784a2398d3eb9329465f7aa8ba Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 7 Jan 2019 15:58:02 +0100 Subject: [PATCH] bpo-32592: Remove Vista code from os.cpu_count() Remove code specific to Windows Vista from os.cpu_count(): Python requires Windows 7 or newer. --- Modules/posixmodule.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index e5c2a9cfc1eccb..c2a4e1968bb093 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -11820,22 +11820,7 @@ os_cpu_count_impl(PyObject *module) { int ncpu = 0; #ifdef MS_WINDOWS - /* Vista is supported and the GetMaximumProcessorCount API is Win7+ - Need to fallback to Vista behavior if this call isn't present */ - HINSTANCE hKernel32; - hKernel32 = GetModuleHandleW(L"KERNEL32"); - - static DWORD(CALLBACK *_GetMaximumProcessorCount)(WORD) = NULL; - *(FARPROC*)&_GetMaximumProcessorCount = GetProcAddress(hKernel32, - "GetMaximumProcessorCount"); - if (_GetMaximumProcessorCount != NULL) { - ncpu = _GetMaximumProcessorCount(ALL_PROCESSOR_GROUPS); - } - else { - SYSTEM_INFO sysinfo; - GetSystemInfo(&sysinfo); - ncpu = sysinfo.dwNumberOfProcessors; - } + ncpu = GetMaximumProcessorCount(ALL_PROCESSOR_GROUPS); #elif defined(__hpux) ncpu = mpctl(MPC_GETNUMSPUS, NULL, NULL); #elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)