]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-152433: Allow posixmodule.c to build for Windows UWP (GH-152998)
authorthexai <58434170+thexai@users.noreply.github.com>
Tue, 14 Jul 2026 21:35:59 +0000 (23:35 +0200)
committerGitHub <noreply@github.com>
Tue, 14 Jul 2026 21:35:59 +0000 (22:35 +0100)
Include/internal/pycore_fileutils_windows.h
Modules/clinic/posixmodule.c.h
Modules/posixmodule.c

index b79aa9fb4653765cb7f171ade2b1570b5c451e9d..4c42f16beb12a4f5fbe5d3ff917372f0cc036105 100644 (file)
@@ -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(
index 00a4f6009186af988bffd955e4495a66d17d50a9..1f7e414b2dfe48f1844a64c75c6ffa3ef2fbf417 100644 (file)
@@ -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 @@ exit:
 #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]*/
index 57db175336702e203dbbe8ed8e29ac8cc3522fb9..36debd6fe7aa153578e7f1982566e6c20f617625 100644 (file)
@@ -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.