https://github.com/python/cpython/commit/4221ce7e3002ea5459ec7cb5543cc1e43f422506
commit: 4221ce7e3002ea5459ec7cb5543cc1e43f422506
branch: main
author: thexai <[email protected]>
committer: zooba <[email protected]>
date: 2026-07-06T17:32:36+01:00
summary:

gh-152433: Allow _ssl module to build for Windows UWP API set (GH-152791)

files:
A Misc/NEWS.d/next/Windows/2026-07-01-16-38-24.gh-issue-152433.jvEiHh.rst
M Modules/_ssl.c
M Modules/_ssl/debughelpers.c

diff --git 
a/Misc/NEWS.d/next/Windows/2026-07-01-16-38-24.gh-issue-152433.jvEiHh.rst 
b/Misc/NEWS.d/next/Windows/2026-07-01-16-38-24.gh-issue-152433.jvEiHh.rst
new file mode 100644
index 000000000000000..d5aead5fbe0b9e2
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2026-07-01-16-38-24.gh-issue-152433.jvEiHh.rst
@@ -0,0 +1 @@
+:mod:`ssl`: improve UWP build compatibility.
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index f451c0ce7364ab9..20564e1ba4165a6 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -4924,16 +4924,16 @@ static PyObject *
 _ssl__SSLContext_load_dh_params_impl(PySSLContext *self, PyObject *filepath)
 /*[clinic end generated code: output=dd74b3c524dd2723 input=832769a0734b8c4d]*/
 {
-    FILE *f;
-    DH *dh;
-
-#if defined(MS_WINDOWS) && defined(Py_DEBUG)
+#if defined(MS_WINDOWS_APP) && !defined(MS_WINDOWS_DESKTOP)
+    PyErr_SetString(PyExc_NotImplementedError, "load_dh_params: unavailable on 
UWP build");
+    return NULL;
+#elif defined(MS_WINDOWS) && defined(Py_DEBUG)
     PyErr_SetString(PyExc_NotImplementedError,
                     "load_dh_params: unavailable on Windows debug build");
     return NULL;
-#endif
-
-    f = Py_fopen(filepath, "rb");
+#else
+    FILE* f = Py_fopen(filepath, "rb");
+    DH* dh;
     if (f == NULL)
         return NULL;
 
@@ -4959,6 +4959,7 @@ _ssl__SSLContext_load_dh_params_impl(PySSLContext *self, 
PyObject *filepath)
     }
     DH_free(dh);
     Py_RETURN_NONE;
+#endif
 }
 
 /*[clinic input]
diff --git a/Modules/_ssl/debughelpers.c b/Modules/_ssl/debughelpers.c
index e0cb7ca9a09f91e..fb9043994f08f9e 100644
--- a/Modules/_ssl/debughelpers.c
+++ b/Modules/_ssl/debughelpers.c
@@ -182,14 +182,17 @@ static int
 _PySSLContext_set_keylog_filename(PyObject *op, PyObject *arg,
                                   void *Py_UNUSED(closure))
 {
-    PySSLContext *self = PySSLContext_CAST(op);
-    FILE *fp;
-
-#if defined(MS_WINDOWS) && defined(Py_DEBUG)
+#if defined(MS_WINDOWS_APP) && !defined(MS_WINDOWS_DESKTOP)
+    PyErr_SetString(PyExc_NotImplementedError,
+                    "set_keylog_filename: unavailable on UWP build");
+    return -1;
+#elif defined(MS_WINDOWS) && defined(Py_DEBUG)
     PyErr_SetString(PyExc_NotImplementedError,
                     "set_keylog_filename: unavailable on Windows debug build");
     return -1;
-#endif
+#else
+    PySSLContext* self = PySSLContext_CAST(op);
+    FILE* fp;
 
     /* Reset variables and callback first */
     SSL_CTX_set_keylog_callback(self->ctx, NULL);
@@ -231,4 +234,5 @@ _PySSLContext_set_keylog_filename(PyObject *op, PyObject 
*arg,
     PySSL_END_ALLOW_THREADS(self)
     SSL_CTX_set_keylog_callback(self->ctx, _PySSL_keylog_callback);
     return 0;
+#endif
 }

_______________________________________________
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