Update
Applied the (below) fix (and a couple of more) to the original sources, built them, and uploaded the .whls to [GitHub]: CristiFati/Prebuilt-Binaries - (master) Prebuilt-Binaries/PyWin32/v228.
But, since this bug is kind of a "deal breaker" (and there are 4+ months since v228 was released), I'm expecting v229 very soon (in the next days or so).
Check the Install steps section from (the beginning of) [SO]: PyWin32 and Python 3.8.0 (@CristiFati's answer) for details on how to install the .whls.
It's constantly reproducible on:
[cfati@CFATI-5510-0:e:\Work\Dev\GitHub\CristiFati\pywin32\src]> sopr.bat
### Set shorter prompt to better fit when pasted in StackOverflow (or other) pages ###
[prompt]> "e:\Work\Dev\VEnvs\py_pc064_03.09.00_test0\Scripts\python.exe"
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32ui
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\Install\pc064\Python\Python\03.09.00\Lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 1114] A dynamic link library (DLL) initialization routine failed
>>> import win32api
I did some debugging (created a VStudio 2015 solution (with 2 projects: for Python 3.9 and Python 3.8) for win32ui), and it turns out it's an Access Violation (segfault).
The "best" part is that it's occurring before DllMain.
One of the last lines that I could get the debugger in, was [GitHub]: mhammond/pywin32 - (b228) pywin32/Pythonwin/win32RichEdit.cpp#225:
PyCCtrlView_Type PyCRichEditView::type("PyCRichEditView", &PyCCtrlView::type, &PyCRichEditCtrl::type,
RUNTIME_CLASS(CRichEditView), sizeof(PyCRichEditView),
PYOBJ_OFFSET(PyCRichEditView), PyCRichEditView_methods,
GET_PY_CTOR(PyCRichEditView));
This is a static member. Since the 2nd and 3rd arguments are also static members (wasn't paying attention to the fact that they're pointers), I thought it was [ISOCPP]: What’s the “static initialization order ‘fiasco’ (problem)”?, and I chased some ghosts.
Anyway, today I noticed [GitHub]: mhammond/pywin32 - Ensure we hold the GIL as win32ui initializes and calls back into Python (and from there [GitHub]: mhammond/pywin32 - Import win32ui broken on Python 3.9 that it's addressing).
Applying the patch, fixes the problem:
[prompt]> "e:\Work\Dev\VEnvs\py_pc064_03.09.00_test0\Scripts\python.exe"
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32ui
>>> import win32api