Skip to content

gh-152433: Windows: _ssl module: improve UWP compatibility#152791

Open
thexai wants to merge 1 commit into
python:mainfrom
thexai:uwp-_ssl
Open

gh-152433: Windows: _ssl module: improve UWP compatibility#152791
thexai wants to merge 1 commit into
python:mainfrom
thexai:uwp-_ssl

Conversation

@thexai

@thexai thexai commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Windows: _ssl module: improve UWP compatibility.

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please use if defined() and elif defined(MS_WINDOWS) && ... and else for the fallback branch.
  • Can you determine why we are only raising a NotImplementedError on MS DEBUG builds for those functions? it's a separate issue but I think we should also raise unconditionally (or does it mean that those functions are available on regular MS builds only in release builds?) If there is something worth investigating, you can open a separate issue for that.

Comment on lines +185 to +189
#ifdef MS_WINDOWS_APP_PURE
PyErr_SetString(PyExc_NotImplementedError,
"set_keylog_filename: unavailable on UWP build");
return -1;
#else

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this large if-else-endif guard is necessary because some symbols are not available on UWP, I'm ok. Otherwise, I would prefer that you simply add an if guard afterwards. It would be dead code in some sense.

I'm actually surprised that we raise NotImplementedError only on MS DEBUG builds though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, that may be because the API passes FILE * across the boundary, and because we always use a release build of OpenSSL even for debug builds of CPython. So it'll (potentially) crash (and will certainly crash if anyone uses fileno on it) becuase the FILE data is in a different instance of the runtime.

Skipping the entire function made more sense than ~doubling the debug build time or redistributing a debug build of libssl.

Comment thread Modules/_ssl.c
PyErr_SetString(PyExc_NotImplementedError, "load_dh_params: unavailable on UWP build");
return NULL;
#else
#if defined(MS_WINDOWS) && defined(Py_DEBUG)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that we raise only on DEBUG MS builds is really weird here. Likewise, I would rather prefer an elif branch instead of a ifdef/else + nested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants