Zachary Ware added the comment:

What about instead of unconditionally calling CoInitializeEx in all cases, add 
a Py_EnsureCOM(flags) C API function?  The flags param would be any flags that 
the caller must have, would default to 0, and would be combined with 
sys.coinit_flags before calling CoInitializeEx.  If CoInitializeEx had already 
been called, the flags are compared with what were used in the call and an 
error is raised in case of conflict.  Otherwise, CoInitializeEx is called and 
the flags are returned.  It could also be exposed to Python code as 
sys.ensure_com, though in the case of something like AMSI being enabled, 
sys.ensure_com would always either be a no-op or raise an error.


Disclaimer: I know exactly nothing about COM, except what I've read in this 
issue and the AMSI issue.  If this suggestion is unworkable, please ignore it 
entirely!

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27417>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to