]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-152433: Allow _ssl module to build for Windows UWP API set (GH-152791)
authorthexai <58434170+thexai@users.noreply.github.com>
Mon, 6 Jul 2026 16:32:36 +0000 (18:32 +0200)
committerGitHub <noreply@github.com>
Mon, 6 Jul 2026 16:32:36 +0000 (17:32 +0100)
Misc/NEWS.d/next/Windows/2026-07-01-16-38-24.gh-issue-152433.jvEiHh.rst [new file with mode: 0644]
Modules/_ssl.c
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 (file)
index 0000000..d5aead5
--- /dev/null
@@ -0,0 +1 @@
+:mod:`ssl`: improve UWP build compatibility.
index f451c0ce7364ab9bace46b1c6eaec28c4705feb5..20564e1ba4165a67d5efe166f8e5e903de79095f 100644 (file)
@@ -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]
index e0cb7ca9a09f91e988faf3b3c31bfc6769719b1f..fb9043994f08f9ee777ec08f4c1665f5c7b5495a 100644 (file)
@@ -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
 }