https://github.com/python/cpython/commit/ab4ee5513b60ba2c3d1389fcc8c54915809ecfef
commit: ab4ee5513b60ba2c3d1389fcc8c54915809ecfef
branch: main
author: thexai <[email protected]>
committer: chris-eibl <[email protected]>
date: 2026-09-11T12:17:26+02:00
summary:

gh-152433: Windows: ``_ctypes`` module: improve UWP compatibility (#152792)

files:
A Misc/NEWS.d/next/Windows/2026-07-01-17-00-52.gh-issue-152433.kSd1bW.rst
M Modules/_ctypes/callproc.c

diff --git 
a/Misc/NEWS.d/next/Windows/2026-07-01-17-00-52.gh-issue-152433.kSd1bW.rst 
b/Misc/NEWS.d/next/Windows/2026-07-01-17-00-52.gh-issue-152433.kSd1bW.rst
new file mode 100644
index 000000000000000..1248edfd54aa2ba
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2026-07-01-17-00-52.gh-issue-152433.kSd1bW.rst
@@ -0,0 +1 @@
+Allow build :mod:`!_ctypes` for Universal Windows Platform.
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 746034c8004c5c4..1f2c49b5878cc70 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -1082,8 +1082,7 @@ void _ctypes_extend_error(PyObject *exc_class, const char 
*fmt, ...)
 }
 
 
-#ifdef MS_WIN32
-
+#ifdef MS_WINDOWS_DESKTOP
 static PyObject *
 GetComError(ctypes_state *st, HRESULT errcode, GUID *riid, IUnknown *pIunk)
 {
@@ -1337,9 +1336,11 @@ PyObject *_ctypes_callproc(ctypes_state *st,
 
 #ifdef MS_WIN32
     if (iid && pIunk) {
+#ifdef MS_WINDOWS_DESKTOP
         if (*(int *)resbuf & 0x80000000)
             retval = GetComError(st, *(HRESULT *)resbuf, iid, pIunk);
         else
+#endif
             retval = PyLong_FromLong(*(int *)resbuf);
     } else if (flags & FUNCFLAG_HRESULT) {
         if (*(int *)resbuf & 0x80000000)

_______________________________________________
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]

Reply via email to