https://github.com/python/cpython/commit/0e8100a140414ceb9086a1d5d7dd24209f111d41
commit: 0e8100a140414ceb9086a1d5d7dd24209f111d41
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-08-29T21:04:01+03:00
summary:
gh-85470: Delay load ole32.dll in the _ctypes module (GH-155435)
ole32.dll pulls in user32.dll, which makes the system treat the process as
a GUI process and stop sending logoff and shutdown console control events
to it. It is only needed for ProgIDFromCLSID() when formatting a COM error.
files:
A Misc/NEWS.d/next/Windows/2026-08-09-15-40-00.gh-issue-85470.Lm4Xt9.rst
M PCbuild/_ctypes.vcxproj
diff --git
a/Misc/NEWS.d/next/Windows/2026-08-09-15-40-00.gh-issue-85470.Lm4Xt9.rst
b/Misc/NEWS.d/next/Windows/2026-08-09-15-40-00.gh-issue-85470.Lm4Xt9.rst
new file mode 100644
index 000000000000000..1d623c890e960b6
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2026-08-09-15-40-00.gh-issue-85470.Lm4Xt9.rst
@@ -0,0 +1,4 @@
+Importing :mod:`ctypes` on Windows no longer loads ``user32.dll``, which
+made the system treat the process as a GUI process and stop sending logoff
+and shutdown console control events to it. ``ole32.dll``, which pulled
+``user32.dll`` in, is now delay loaded.
diff --git a/PCbuild/_ctypes.vcxproj b/PCbuild/_ctypes.vcxproj
index 63d5fa49cd4e17a..e56d812d78dcd80 100644
--- a/PCbuild/_ctypes.vcxproj
+++ b/PCbuild/_ctypes.vcxproj
@@ -98,6 +98,7 @@
</ClCompile>
<Link>
<AdditionalOptions>/EXPORT:DllGetClassObject,PRIVATE
/EXPORT:DllCanUnloadNow,PRIVATE %(AdditionalOptions)</AdditionalOptions>
+ <DelayLoadDLLs>ole32.dll</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]