Skip to content

Commit dd325fd

Browse files
committed
pythongh-152433: Allow posixmodule.c to build for Windows UWP (pythonGH-152998)
1 parent 2f58162 commit dd325fd

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

‎Include/internal/pycore_fileutils_windows.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ static inline BOOL _Py_GetFileInformationByName(
5555
static int GetFileInformationByName_init = -1;
5656

5757
if (GetFileInformationByName_init < 0) {
58+
#ifdef MS_WINDOWS_DESKTOP
5859
HMODULE hMod = LoadLibraryW(L"api-ms-win-core-file-l2-1-4");
60+
#else
61+
HMODULE hMod = LoadPackagedLibrary(L"api-ms-win-core-file-l2-1-4", 0);
62+
#endif
5963
GetFileInformationByName_init = 0;
6064
if (hMod) {
6165
GetFileInformationByName = (PGetFileInformationByName)GetProcAddress(

‎Modules/clinic/posixmodule.c.h‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Modules/posixmodule.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5205,7 +5205,7 @@ os_listdrives_impl(PyObject *module)
52055205

52065206
#endif /* MS_WINDOWS_DESKTOP || MS_WINDOWS_SYSTEM */
52075207

5208-
#if defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)
5208+
#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
52095209

52105210
/*[clinic input]
52115211
os.listvolumes
@@ -5268,7 +5268,7 @@ os_listvolumes_impl(PyObject *module)
52685268
return result;
52695269
}
52705270

5271-
#endif /* MS_WINDOWS_APP || MS_WINDOWS_SYSTEM */
5271+
#endif /* MS_WINDOWS_DESKTOP || MS_WINDOWS_SYSTEM */
52725272

52735273
#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
52745274

@@ -9941,6 +9941,7 @@ os_setpgrp_impl(PyObject *module)
99419941
#include <winternl.h>
99429942
#include <ProcessSnapshot.h>
99439943

9944+
#ifdef MS_WINDOWS_DESKTOP
99449945
// The structure definition in winternl.h may be incomplete.
99459946
// This structure is the full version from the MSDN documentation.
99469947
typedef struct _PROCESS_BASIC_INFORMATION_FULL {
@@ -10013,6 +10014,7 @@ win32_getppid_fast(void)
1001310014
cached_ppid = (ULONG) basic_information.InheritedFromUniqueProcessId;
1001410015
return cached_ppid;
1001510016
}
10017+
#endif // MS_WINDOWS_DESKTOP
1001610018

1001710019
static PyObject*
1001810020
win32_getppid(void)
@@ -10021,12 +10023,13 @@ win32_getppid(void)
1002110023
PyObject* result = NULL;
1002210024
HANDLE process = GetCurrentProcess();
1002310025
HPSS snapshot = NULL;
10024-
ULONG pid;
1002510026

10026-
pid = win32_getppid_fast();
10027+
#ifdef MS_WINDOWS_DESKTOP
10028+
ULONG pid = win32_getppid_fast();
1002710029
if (pid != 0) {
1002810030
return PyLong_FromUnsignedLong(pid);
1002910031
}
10032+
#endif
1003010033

1003110034
// If failure occurs in win32_getppid_fast(), fall back to using the PSS API.
1003210035

0 commit comments

Comments
 (0)