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 00000000000000..f7a7adc2cdfc1c --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2026-07-01-16-38-24.gh-issue-152433.jvEiHh.rst @@ -0,0 +1 @@ +``_ssl`` module: improve UWP compatibility. diff --git a/Modules/_ssl.c b/Modules/_ssl.c index f451c0ce7364ab..10a66402248e97 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -4924,16 +4924,18 @@ 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_DESKTOP) && defined(MS_WINDOWS_APP) + PyErr_SetString(PyExc_NotImplementedError, "load_dh_params: unavailable on UWP build"); + return NULL; +#else #if 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"); + FILE* f = Py_fopen(filepath, "rb"); + DH* dh; if (f == NULL) return NULL; @@ -4959,6 +4961,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 e0cb7ca9a09f91..ec35ec5ca16bd7 100644 --- a/Modules/_ssl/debughelpers.c +++ b/Modules/_ssl/debughelpers.c @@ -182,14 +182,18 @@ 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_DESKTOP) && defined(MS_WINDOWS_APP) + PyErr_SetString(PyExc_NotImplementedError, + "set_keylog_filename: unavailable on UWP build"); + return -1; +#else #if defined(MS_WINDOWS) && defined(Py_DEBUG) PyErr_SetString(PyExc_NotImplementedError, "set_keylog_filename: unavailable on Windows debug build"); return -1; #endif + PySSLContext* self = PySSLContext_CAST(op); + FILE* fp; /* Reset variables and callback first */ SSL_CTX_set_keylog_callback(self->ctx, NULL); @@ -231,4 +235,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 }