Skip to content

Commit 72caa80

Browse files
committed
gh-152433: Windows: _ssl module: improve UWP compatibility
1 parent b52bc56 commit 72caa80

3 files changed

Lines changed: 18 additions & 12 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:mod:`ssl`: improve UWP build compatibility.

Modules/_ssl.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4924,16 +4924,16 @@ static PyObject *
49244924
_ssl__SSLContext_load_dh_params_impl(PySSLContext *self, PyObject *filepath)
49254925
/*[clinic end generated code: output=dd74b3c524dd2723 input=832769a0734b8c4d]*/
49264926
{
4927-
FILE *f;
4928-
DH *dh;
4929-
4930-
#if defined(MS_WINDOWS) && defined(Py_DEBUG)
4927+
#if defined(MS_WINDOWS_APP) && !defined(MS_WINDOWS_DESKTOP)
4928+
PyErr_SetString(PyExc_NotImplementedError, "load_dh_params: unavailable on UWP build");
4929+
return NULL;
4930+
#elif defined(MS_WINDOWS) && defined(Py_DEBUG)
49314931
PyErr_SetString(PyExc_NotImplementedError,
49324932
"load_dh_params: unavailable on Windows debug build");
49334933
return NULL;
4934-
#endif
4935-
4936-
f = Py_fopen(filepath, "rb");
4934+
#else
4935+
FILE* f = Py_fopen(filepath, "rb");
4936+
DH* dh;
49374937
if (f == NULL)
49384938
return NULL;
49394939

@@ -4959,6 +4959,7 @@ _ssl__SSLContext_load_dh_params_impl(PySSLContext *self, PyObject *filepath)
49594959
}
49604960
DH_free(dh);
49614961
Py_RETURN_NONE;
4962+
#endif
49624963
}
49634964

49644965
/*[clinic input]

Modules/_ssl/debughelpers.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,17 @@ static int
182182
_PySSLContext_set_keylog_filename(PyObject *op, PyObject *arg,
183183
void *Py_UNUSED(closure))
184184
{
185-
PySSLContext *self = PySSLContext_CAST(op);
186-
FILE *fp;
187-
188-
#if defined(MS_WINDOWS) && defined(Py_DEBUG)
185+
#if defined(MS_WINDOWS_APP) && !defined(MS_WINDOWS_DESKTOP)
186+
PyErr_SetString(PyExc_NotImplementedError,
187+
"set_keylog_filename: unavailable on UWP build");
188+
return -1;
189+
#elif defined(MS_WINDOWS) && defined(Py_DEBUG)
189190
PyErr_SetString(PyExc_NotImplementedError,
190191
"set_keylog_filename: unavailable on Windows debug build");
191192
return -1;
192-
#endif
193+
#else
194+
PySSLContext* self = PySSLContext_CAST(op);
195+
FILE* fp;
193196

194197
/* Reset variables and callback first */
195198
SSL_CTX_set_keylog_callback(self->ctx, NULL);
@@ -231,4 +234,5 @@ _PySSLContext_set_keylog_filename(PyObject *op, PyObject *arg,
231234
PySSL_END_ALLOW_THREADS(self)
232235
SSL_CTX_set_keylog_callback(self->ctx, _PySSL_keylog_callback);
233236
return 0;
237+
#endif
234238
}

0 commit comments

Comments
 (0)