Skip to content

Commit 834b4c3

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

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

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

‎Modules/_ssl.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4924,16 +4924,18 @@ 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-
4927+
#if !defined(MS_WINDOWS_DESKTOP) && defined(MS_WINDOWS_APP)
4928+
PyErr_SetString(PyExc_NotImplementedError, "load_dh_params: unavailable on UWP build");
4929+
return NULL;
4930+
#else
49304931
#if defined(MS_WINDOWS) && defined(Py_DEBUG)
49314932
PyErr_SetString(PyExc_NotImplementedError,
49324933
"load_dh_params: unavailable on Windows debug build");
49334934
return NULL;
49344935
#endif
49354936

4936-
f = Py_fopen(filepath, "rb");
4937+
FILE* f = Py_fopen(filepath, "rb");
4938+
DH* dh;
49374939
if (f == NULL)
49384940
return NULL;
49394941

@@ -4959,6 +4961,7 @@ _ssl__SSLContext_load_dh_params_impl(PySSLContext *self, PyObject *filepath)
49594961
}
49604962
DH_free(dh);
49614963
Py_RETURN_NONE;
4964+
#endif
49624965
}
49634966

49644967
/*[clinic input]

‎Modules/_ssl/debughelpers.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,18 @@ 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-
185+
#if !defined(MS_WINDOWS_DESKTOP) && defined(MS_WINDOWS_APP)
186+
PyErr_SetString(PyExc_NotImplementedError,
187+
"set_keylog_filename: unavailable on UWP build");
188+
return -1;
189+
#else
188190
#if defined(MS_WINDOWS) && defined(Py_DEBUG)
189191
PyErr_SetString(PyExc_NotImplementedError,
190192
"set_keylog_filename: unavailable on Windows debug build");
191193
return -1;
192194
#endif
195+
PySSLContext* self = PySSLContext_CAST(op);
196+
FILE* fp;
193197

194198
/* Reset variables and callback first */
195199
SSL_CTX_set_keylog_callback(self->ctx, NULL);
@@ -231,4 +235,5 @@ _PySSLContext_set_keylog_filename(PyObject *op, PyObject *arg,
231235
PySSL_END_ALLOW_THREADS(self)
232236
SSL_CTX_set_keylog_callback(self->ctx, _PySSL_keylog_callback);
233237
return 0;
238+
#endif
234239
}

0 commit comments

Comments
 (0)