https://github.com/python/cpython/commit/ba289460069fbdb5b035b48c5c0ba667d42a7ab9
commit: ba289460069fbdb5b035b48c5c0ba667d42a7ab9
branch: main
author: thexai <[email protected]>
committer: zooba <[email protected]>
date: 2026-07-14T22:35:59+01:00
summary:
gh-152433: Allow posixmodule.c to build for Windows UWP (GH-152998)
files:
M Include/internal/pycore_fileutils_windows.h
M Modules/clinic/posixmodule.c.h
M Modules/posixmodule.c
diff --git a/Include/internal/pycore_fileutils_windows.h
b/Include/internal/pycore_fileutils_windows.h
index b79aa9fb4653765..4c42f16beb12a4f 100644
--- a/Include/internal/pycore_fileutils_windows.h
+++ b/Include/internal/pycore_fileutils_windows.h
@@ -55,7 +55,11 @@ static inline BOOL _Py_GetFileInformationByName(
static int GetFileInformationByName_init = -1;
if (GetFileInformationByName_init < 0) {
+#ifdef MS_WINDOWS_DESKTOP
HMODULE hMod = LoadLibraryW(L"api-ms-win-core-file-l2-1-4");
+#else
+ HMODULE hMod = LoadPackagedLibrary(L"api-ms-win-core-file-l2-1-4", 0);
+#endif
GetFileInformationByName_init = 0;
if (hMod) {
GetFileInformationByName =
(PGetFileInformationByName)GetProcAddress(
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
index 00a4f6009186af9..1f7e414b2dfe48f 100644
--- a/Modules/clinic/posixmodule.c.h
+++ b/Modules/clinic/posixmodule.c.h
@@ -1851,7 +1851,7 @@ os_listdrives(PyObject *module, PyObject
*Py_UNUSED(ignored))
#endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)) */
-#if (defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM))
+#if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM))
PyDoc_STRVAR(os_listvolumes__doc__,
"listvolumes($module, /)\n"
@@ -1873,7 +1873,7 @@ os_listvolumes(PyObject *module, PyObject
*Py_UNUSED(ignored))
return os_listvolumes_impl(module);
}
-#endif /* (defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)) */
+#endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)) */
#if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM))
@@ -13733,4 +13733,4 @@ os__emscripten_log(PyObject *module, PyObject *const
*args, Py_ssize_t nargs, Py
#ifndef OS__EMSCRIPTEN_LOG_METHODDEF
#define OS__EMSCRIPTEN_LOG_METHODDEF
#endif /* !defined(OS__EMSCRIPTEN_LOG_METHODDEF) */
-/*[clinic end generated code: output=250ea2e34fdd133f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d81494ceb6ce44ed input=a9049054013a1b77]*/
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 57db175336702e2..36debd6fe7aa153 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5197,7 +5197,7 @@ os_listdrives_impl(PyObject *module)
#endif /* MS_WINDOWS_DESKTOP || MS_WINDOWS_SYSTEM */
-#if defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)
+#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
/*[clinic input]
os.listvolumes
@@ -5260,7 +5260,7 @@ os_listvolumes_impl(PyObject *module)
return result;
}
-#endif /* MS_WINDOWS_APP || MS_WINDOWS_SYSTEM */
+#endif /* MS_WINDOWS_DESKTOP || MS_WINDOWS_SYSTEM */
#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
@@ -9933,6 +9933,7 @@ os_setpgrp_impl(PyObject *module)
#include <winternl.h>
#include <ProcessSnapshot.h>
+#ifdef MS_WINDOWS_DESKTOP
// The structure definition in winternl.h may be incomplete.
// This structure is the full version from the MSDN documentation.
typedef struct _PROCESS_BASIC_INFORMATION_FULL {
@@ -10005,6 +10006,7 @@ win32_getppid_fast(void)
cached_ppid = (ULONG) basic_information.InheritedFromUniqueProcessId;
return cached_ppid;
}
+#endif // MS_WINDOWS_DESKTOP
static PyObject*
win32_getppid(void)
@@ -10013,12 +10015,13 @@ win32_getppid(void)
PyObject* result = NULL;
HANDLE process = GetCurrentProcess();
HPSS snapshot = NULL;
- ULONG pid;
- pid = win32_getppid_fast();
+#ifdef MS_WINDOWS_DESKTOP
+ ULONG pid = win32_getppid_fast();
if (pid != 0) {
return PyLong_FromUnsignedLong(pid);
}
+#endif
// If failure occurs in win32_getppid_fast(), fall back to using the PSS
API.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]