summaryrefslogtreecommitdiffstats
path: root/Modules/_winapi.c
diff options
context:
space:
mode:
authorMax Bachmann <kontakt@maxbachmann.de>2023-03-01 00:31:21 (GMT)
committerGitHub <noreply@github.com>2023-03-01 00:31:21 (GMT)
commit938e36f824c5f834d6b77d47942ad81edd5491d0 (patch)
tree50995f866619e76b3ce900c60859ab64e4e0621c /Modules/_winapi.c
parent360ef843d8fc03aad38ed84f9f45026ab08ca4f4 (diff)
downloadcpython-938e36f824c5f834d6b77d47942ad81edd5491d0.zip
cpython-938e36f824c5f834d6b77d47942ad81edd5491d0.tar.gz
cpython-938e36f824c5f834d6b77d47942ad81edd5491d0.tar.bz2
gh-102336: Remove code specifically for handling Windows 7 (GH-102337)
Diffstat (limited to 'Modules/_winapi.c')
-rw-r--r--Modules/_winapi.c31
1 files changed, 6 insertions, 25 deletions
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index f4d982b..8c4c725 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -63,23 +63,6 @@
#define T_HANDLE T_POINTER
-/* Grab CancelIoEx dynamically from kernel32 */
-static int has_CancelIoEx = -1;
-static BOOL (CALLBACK *Py_CancelIoEx)(HANDLE, LPOVERLAPPED);
-
-static int
-check_CancelIoEx()
-{
- if (has_CancelIoEx == -1)
- {
- HINSTANCE hKernel32 = GetModuleHandle("KERNEL32");
- * (FARPROC *) &Py_CancelIoEx = GetProcAddress(hKernel32,
- "CancelIoEx");
- has_CancelIoEx = (Py_CancelIoEx != NULL);
- }
- return has_CancelIoEx;
-}
-
typedef struct {
PyTypeObject *overlapped_type;
} WinApiState;
@@ -134,8 +117,7 @@ overlapped_dealloc(OverlappedObject *self)
PyObject_GC_UnTrack(self);
if (self->pending) {
- if (check_CancelIoEx() &&
- Py_CancelIoEx(self->handle, &self->overlapped) &&
+ if (CancelIoEx(self->handle, &self->overlapped) &&
GetOverlappedResult(self->handle, &self->overlapped, &bytes, TRUE))
{
/* The operation is no longer pending -- nothing to do. */
@@ -306,10 +288,7 @@ _winapi_Overlapped_cancel_impl(OverlappedObject *self)
if (self->pending) {
Py_BEGIN_ALLOW_THREADS
- if (check_CancelIoEx())
- res = Py_CancelIoEx(self->handle, &self->overlapped);
- else
- res = CancelIo(self->handle);
+ CancelIoEx(self->handle, &self->overlapped);
Py_END_ALLOW_THREADS
}
@@ -655,8 +634,10 @@ _winapi_CreateJunction_impl(PyObject *module, LPCWSTR src_path,
cleanup:
ret = GetLastError();
- CloseHandle(token);
- CloseHandle(junction);
+ if (token != NULL)
+ CloseHandle(token);
+ if (junction != NULL)
+ CloseHandle(junction);
PyMem_RawFree(rdb);
if (ret != 0)