Skip to content

Commit 7e87741

Browse files
committed
gh-152433: Windows: allow posixmodule.c to build for Windows UWP
1 parent 8b1dbb1 commit 7e87741

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow ``posixmodule.c`` to build for Windows UWP.

Modules/clinic/posixmodule.c.h

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

Modules/posixmodule.c

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

51985198
#endif /* MS_WINDOWS_DESKTOP || MS_WINDOWS_SYSTEM */
51995199

5200-
#if defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)
5200+
#if defined(MS_MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
52015201

52025202
/*[clinic input]
52035203
os.listvolumes
@@ -5260,7 +5260,7 @@ os_listvolumes_impl(PyObject *module)
52605260
return result;
52615261
}
52625262

5263-
#endif /* MS_WINDOWS_APP || MS_WINDOWS_SYSTEM */
5263+
#endif /* MS_WINDOWS_DESKTOP || MS_WINDOWS_SYSTEM */
52645264

52655265
#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
52665266

@@ -9933,6 +9933,7 @@ os_setpgrp_impl(PyObject *module)
99339933
#include <winternl.h>
99349934
#include <ProcessSnapshot.h>
99359935

9936+
#ifdef MS_WINDOWS_DESKTOP
99369937
// The structure definition in winternl.h may be incomplete.
99379938
// This structure is the full version from the MSDN documentation.
99389939
typedef struct _PROCESS_BASIC_INFORMATION_FULL {
@@ -10005,6 +10006,7 @@ win32_getppid_fast(void)
1000510006
cached_ppid = (ULONG) basic_information.InheritedFromUniqueProcessId;
1000610007
return cached_ppid;
1000710008
}
10009+
#endif // MS_WINDOWS_DESKTOP
1000810010

1000910011
static PyObject*
1001010012
win32_getppid(void)
@@ -10013,12 +10015,13 @@ win32_getppid(void)
1001310015
PyObject* result = NULL;
1001410016
HANDLE process = GetCurrentProcess();
1001510017
HPSS snapshot = NULL;
10016-
ULONG pid;
1001710018

10018-
pid = win32_getppid_fast();
10019+
#ifdef MS_WINDOWS_DESKTOP
10020+
ULONG pid = win32_getppid_fast();
1001910021
if (pid != 0) {
1002010022
return PyLong_FromUnsignedLong(pid);
1002110023
}
10024+
#endif
1002210025

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

@@ -15227,6 +15230,7 @@ os_abort_impl(PyObject *module)
1522715230
}
1522815231

1522915232
#ifdef MS_WINDOWS
15233+
#ifdef MS_WINDOWS_DESKTOP
1523015234
/* Grab ShellExecute dynamically from shell32 */
1523115235
static int has_ShellExecute = -1;
1523215236
static HINSTANCE (CALLBACK *Py_ShellExecuteW)(HWND, LPCWSTR, LPCWSTR, LPCWSTR,
@@ -15255,6 +15259,7 @@ check_ShellExecute(void)
1525515259
}
1525615260
return has_ShellExecute;
1525715261
}
15262+
#endif // MS_WINDOWS_DESKTOP
1525815263

1525915264

1526015265
/*[clinic input]
@@ -15299,6 +15304,9 @@ os_startfile_impl(PyObject *module, path_t *filepath,
1529915304
path_t *cwd, int show_cmd)
1530015305
/*[clinic end generated code: output=1c6f2f3340e31ffa input=8248997b80669622]*/
1530115306
{
15307+
#if defined(MS_WINDOWS_APP) && !defined(MS_WINDOWS_DESKTOP)
15308+
return PyErr_Format(PyExc_NotImplementedError, "startfile not available on UWP");
15309+
#else
1530215310
HINSTANCE rc;
1530315311

1530415312
if(!check_ShellExecute()) {
@@ -15327,6 +15335,7 @@ os_startfile_impl(PyObject *module, path_t *filepath,
1532715335
return NULL;
1532815336
}
1532915337
Py_RETURN_NONE;
15338+
#endif
1533015339
}
1533115340
#endif /* MS_WINDOWS */
1533215341

0 commit comments

Comments
 (0)