comtypes 1.4.11__zip → 1.4.12__zip
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {comtypes-1.4.11 → comtypes-1.4.12}/CHANGES.txt +26 -0
- {comtypes-1.4.11/comtypes.egg-info → comtypes-1.4.12}/PKG-INFO +2 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/README.md +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/__init__.py +8 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/_comobject.py +6 -6
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/_memberspec.py +7 -7
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/_npsupport.py +12 -17
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/_post_coinit/_cominterface_meta_patcher.py +5 -5
- comtypes-1.4.12/comtypes/_post_coinit/activeobj.py +61 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/_post_coinit/misc.py +1 -23
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/_post_coinit/unknwn.py +4 -6
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/_vtbl.py +3 -3
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/automation.py +10 -13
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/client/__init__.py +2 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/client/_activeobj.py +8 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/client/_code_cache.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/client/_constants.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/client/_events.py +6 -6
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/client/_generate.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/client/dynamic.py +3 -3
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/client/lazybind.py +3 -3
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/errorinfo.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/hresult.py +68 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/messageloop.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/patcher.py +2 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/persist.py +9 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/safearray.py +10 -10
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/server/__init__.py +5 -37
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/server/automation.py +2 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/server/connectionpoints.py +3 -3
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/server/inprocserver.py +2 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/server/localserver.py +3 -3
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/server/register.py +5 -5
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_agilent.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_client_dynamic.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_comserver.py +7 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_createwrappers.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_dispifc_records.py +0 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_dispifc_safearrays.py +0 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_dispinterface.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_excel.py +1 -3
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_getactiveobj.py +19 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_hresult.py +39 -0
- comtypes-1.4.12/comtypes/test/test_messageloop.py +117 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_midl_safearray_create.py +0 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_msscript.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_npsupport.py +22 -11
- comtypes-1.4.12/comtypes/test/test_persist.py +71 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_recordinfo.py +0 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_server.py +6 -6
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_storage.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_stream.py +22 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_urlhistory.py +1 -1
- comtypes-1.4.12/comtypes/test/test_util.py +227 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_variant.py +41 -24
- comtypes-1.4.12/comtypes/test/test_viewobject.py +78 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_word.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/tools/codegenerator/codegenerator.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/tools/codegenerator/comments.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/tools/codegenerator/heads.py +5 -5
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/tools/codegenerator/helpers.py +7 -7
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/tools/codegenerator/namespaces.py +3 -3
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/tools/codegenerator/typeannotator.py +2 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/tools/tlbparser.py +1 -1
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/tools/typedesc.py +14 -14
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/tools/typedesc_base.py +19 -19
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/util.py +38 -6
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/viewobject.py +29 -5
- {comtypes-1.4.11 → comtypes-1.4.12/comtypes.egg-info}/PKG-INFO +2 -2
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes.egg-info/SOURCES.txt +4 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/pyproject.toml +12 -1
- comtypes-1.4.11/comtypes/test/test_persist.py +0 -38
- {comtypes-1.4.11 → comtypes-1.4.12}/LICENSE.txt +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/MANIFEST.in +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/GUID.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/_meta.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/_post_coinit/__init__.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/_post_coinit/bstr.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/_post_coinit/instancemethod.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/_safearray.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/_tlib_version_checker.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/clear_cache.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/client/_create.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/client/_managing.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/connectionpoints.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/git.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/hints.pyi +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/logutil.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/server/w_getopt.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/shelllink.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/stream.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/TestComServer.idl +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/TestComServer.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/TestComServer.tlb +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/TestDispServer.idl +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/TestDispServer.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/TestDispServer.tlb +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/__init__.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/find_memleak.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/mylib.idl +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/mylib.tlb +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/mytypelib.idl +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/runtests.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/setup.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_BSTR.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_DISPPARAMS.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_GUID.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_QueryService.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_avmc.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_basic.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_casesensitivity.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_clear_cache.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_client.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_client_regenerate_modules.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_collections.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_comobject.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_dict.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_dyndispatch.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_errorinfo.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_findgendir.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_ie.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_ienum.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_imfattributes.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_inout_args.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_jscript.js +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_monikers.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_outparam.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_pump_events.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_safearray.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_sapi.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_server_register.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_shelllink.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_showevents.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_subinterface.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_typeannotator.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_typeinfo.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_w_getopt.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_win32com_interop.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/test_wmi.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/test/urlhist.tlb +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/tools/__init__.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/tools/codegenerator/__init__.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/tools/codegenerator/modulenamer.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/tools/codegenerator/packing.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes/typeinfo.py +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes.egg-info/dependency_links.txt +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes.egg-info/entry_points.txt +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/comtypes.egg-info/top_level.txt +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/setup.cfg +0 -0
- {comtypes-1.4.11 → comtypes-1.4.12}/setup.py +0 -0
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
Comtypes CHANGELOG
|
|
2
2
|
==================
|
|
3
3
|
|
|
4
|
+
Release 1.4.12
|
|
5
|
+
--------------
|
|
6
|
+
* Add support for coverage. By @moi15moi.
|
|
7
|
+
* CI/CD Improvements for runners and the codecov badge. By @junkmd.
|
|
8
|
+
* Add signed 32-bit hexadecimal converters. By @junkmd.
|
|
9
|
+
* Add ``Test_Stat`` to ``test_stream``. By @junkmd.
|
|
10
|
+
* Add client-side ``RegisterActiveObject``. By @junkmd.
|
|
11
|
+
* Remove useless ``object`` inheritance from every class. By @moi15moi.
|
|
12
|
+
* Modernize ``super()`` calls by removing explicit class and instance arguments. By @moi15moi.
|
|
13
|
+
* Eliminate outdated encoding boilerplates. By @moi15moi.
|
|
14
|
+
* Update byte string creation to use ``b""`` instead of ``str.encode("utf-8")``. By @moi15moi.
|
|
15
|
+
* Introduce ``codecov.yml``. By @moi15moi.
|
|
16
|
+
* Migrate exception catches from older aliases to ``OSError``. By @moi15moi.
|
|
17
|
+
* Remove obsolete Python 2 compatibility code in ``test_variant``. By @junkmd.
|
|
18
|
+
* Skip ``test_eval`` in INPROC server tests due to instability. By @junkmd.
|
|
19
|
+
* Adjust structure sizes and alignments for 64-bit Python in ``viewobject.py``. By @junkmd.
|
|
20
|
+
* Add ``test_viewobject``. By @junkmd.
|
|
21
|
+
* Ensure ``test_npsupport`` passes with ``numpy>=2.0.0`` by explicitly setting ``dtype=numpy.int32``. By @junkmd.
|
|
22
|
+
* Add tests for ``DictPropertyBag`` and type hints for ``IPropertyBag``. By @junkmd.
|
|
23
|
+
* Fix ``numpy`` interoperability and enable ``datetime64`` tests. By @junkmd.
|
|
24
|
+
* Revive and correct integer handling logic for ``VARIANT``s when setting values. By @junkmd.
|
|
25
|
+
* Add tests for ``messageloop``. By @junkmd.
|
|
26
|
+
* Revive ``util`` and add comprehensive tests. By @junkmd.
|
|
27
|
+
* Refactor and enhance ``util`` with explicit imports and typing. By @junkmd.
|
|
28
|
+
* Modernize ``npsupport`` by removing the patch for the ``np._typecodes``. By @junkmd.
|
|
29
|
+
|
|
4
30
|
Release 1.4.11
|
|
5
31
|
--------------
|
|
6
32
|
* Improve ``PARAMFLAG_...`` and ``DISPATCH_...`` constants definitions and imports. By @junkmd.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: comtypes
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.12
|
|
4
4
|
Summary: Pure Python COM package
|
|
5
5
|
Home-page: https://github.com/enthought/comtypes
|
|
6
6
|
Download-URL: https://github.com/enthought/comtypes/releases
|
|
@@ -25,7 +25,7 @@ Dynamic: license-file
|
|
|
25
25
|
[](https://pypi.org/project/comtypes/) [](https://pypi.org/project/comtypes/) [](https://pypi.org/project/comtypes/)
|
|
26
26
|
[](https://pypi.org/project/comtypes/) [](https://pypi.org/project/comtypes/)
|
|
27
27
|
[](https://github.com/enthought/comtypes/stargazers) [](https://github.com/enthought/comtypes/network/members) [](https://github.com/astral-sh/ruff)
|
|
28
|
-
[](https://tidelift.com/subscription/pkg/pypi-comtypes?utm_source=pypi-comtypes&utm_medium=readme)
|
|
28
|
+
[](https://tidelift.com/subscription/pkg/pypi-comtypes?utm_source=pypi-comtypes&utm_medium=readme) [](https://app.codecov.io/github/enthought/comtypes)
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
`comtypes` is a lightweight pure Python [COM](https://learn.microsoft.com/en-us/windows/win32/com/component-object-model--com--portal) package based on the [`ctypes`](https://docs.python.org/library/ctypes.html) foreign function interface library.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://pypi.org/project/comtypes/) [](https://pypi.org/project/comtypes/) [](https://pypi.org/project/comtypes/)
|
|
5
5
|
[](https://pypi.org/project/comtypes/) [](https://pypi.org/project/comtypes/)
|
|
6
6
|
[](https://github.com/enthought/comtypes/stargazers) [](https://github.com/enthought/comtypes/network/members) [](https://github.com/astral-sh/ruff)
|
|
7
|
-
[](https://tidelift.com/subscription/pkg/pypi-comtypes?utm_source=pypi-comtypes&utm_medium=readme)
|
|
7
|
+
[](https://tidelift.com/subscription/pkg/pypi-comtypes?utm_source=pypi-comtypes&utm_medium=readme) [](https://app.codecov.io/github/enthought/comtypes)
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
`comtypes` is a lightweight pure Python [COM](https://learn.microsoft.com/en-us/windows/win32/com/component-object-model--com--portal) package based on the [`ctypes`](https://docs.python.org/library/ctypes.html) foreign function interface library.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# comtypes version numbers follow semver (http://semver.org/) and PEP 440
|
|
2
|
-
__version__ = "1.4.
|
|
2
|
+
__version__ = "1.4.12"
|
|
3
3
|
|
|
4
4
|
try:
|
|
5
5
|
from _ctypes import COMError # noqa
|
|
@@ -213,12 +213,18 @@ from comtypes._post_coinit.misc import IPersist, IServiceProvider # noqa
|
|
|
213
213
|
|
|
214
214
|
|
|
215
215
|
from comtypes._post_coinit.instancemethod import instancemethod # noqa
|
|
216
|
+
from comtypes._post_coinit.activeobj import ( # noqa
|
|
217
|
+
ACTIVEOBJECT_STRONG,
|
|
218
|
+
ACTIVEOBJECT_WEAK,
|
|
219
|
+
GetActiveObject,
|
|
220
|
+
RegisterActiveObject,
|
|
221
|
+
RevokeActiveObject,
|
|
222
|
+
)
|
|
216
223
|
from comtypes._post_coinit.misc import ( # noqa
|
|
217
224
|
_is_object,
|
|
218
225
|
CoGetObject,
|
|
219
226
|
CoCreateInstance,
|
|
220
227
|
CoGetClassObject,
|
|
221
|
-
GetActiveObject,
|
|
222
228
|
MULTI_QI,
|
|
223
229
|
_COAUTHIDENTITY,
|
|
224
230
|
COAUTHIDENTITY,
|
|
@@ -144,7 +144,7 @@ _PostQuitMessage.argtypes = [INT]
|
|
|
144
144
|
_PostQuitMessage.restype = None
|
|
145
145
|
|
|
146
146
|
|
|
147
|
-
class LocalServer
|
|
147
|
+
class LocalServer:
|
|
148
148
|
_queue: Optional[queue.Queue] = None
|
|
149
149
|
|
|
150
150
|
def run(self, classobjects: Sequence["hints.localserver.ClassFactory"]) -> None:
|
|
@@ -186,7 +186,7 @@ class LocalServer(object):
|
|
|
186
186
|
_PostQuitMessage(0)
|
|
187
187
|
|
|
188
188
|
|
|
189
|
-
class InprocServer
|
|
189
|
+
class InprocServer:
|
|
190
190
|
def __init__(self) -> None:
|
|
191
191
|
self.locks = c_long(0)
|
|
192
192
|
|
|
@@ -207,7 +207,7 @@ class InprocServer(object):
|
|
|
207
207
|
_T_IUnknown = TypeVar("_T_IUnknown", bound=IUnknown)
|
|
208
208
|
|
|
209
209
|
|
|
210
|
-
class COMObject
|
|
210
|
+
class COMObject:
|
|
211
211
|
_com_interfaces_: ClassVar[List[Type[IUnknown]]]
|
|
212
212
|
_outgoing_interfaces_: ClassVar[List[Type["hints.IDispatch"]]]
|
|
213
213
|
_instances_: ClassVar[Dict["COMObject", None]] = {}
|
|
@@ -218,7 +218,7 @@ class COMObject(object):
|
|
|
218
218
|
_dispimpl_: Dict[Tuple[comtypes.dispid, int], Callable[..., Any]]
|
|
219
219
|
|
|
220
220
|
def __new__(cls, *args: Any, **kw: Any) -> "hints.Self":
|
|
221
|
-
self = super(
|
|
221
|
+
self = super().__new__(cls)
|
|
222
222
|
if isinstance(self, c_void_p):
|
|
223
223
|
# We build the VTables only for direct instances of
|
|
224
224
|
# CoClass, not for POINTERs to CoClass.
|
|
@@ -414,7 +414,7 @@ class COMObject(object):
|
|
|
414
414
|
try:
|
|
415
415
|
self.__typelib
|
|
416
416
|
except AttributeError:
|
|
417
|
-
raise
|
|
417
|
+
raise OSError(hresult.E_NOTIMPL)
|
|
418
418
|
return self.__typelib.GetTypeInfoOfGuid(self._reg_clsid_)
|
|
419
419
|
|
|
420
420
|
################################################################
|
|
@@ -422,7 +422,7 @@ class COMObject(object):
|
|
|
422
422
|
|
|
423
423
|
def IProvideClassInfo2_GetGUID(self, dwGuidKind: int) -> GUID:
|
|
424
424
|
if dwGuidKind != GUIDKIND_DEFAULT_SOURCE_DISP_IID:
|
|
425
|
-
raise
|
|
425
|
+
raise OSError(hresult.E_INVALIDARG)
|
|
426
426
|
return self._outgoing_interfaces_[0]._iid_
|
|
427
427
|
|
|
428
428
|
################################################################
|
|
@@ -162,7 +162,7 @@ class helpstring(str):
|
|
|
162
162
|
"Specifies the helpstring for a COM method or property."
|
|
163
163
|
|
|
164
164
|
|
|
165
|
-
class defaultvalue
|
|
165
|
+
class defaultvalue:
|
|
166
166
|
"Specifies the default value for parameters marked optional."
|
|
167
167
|
|
|
168
168
|
def __init__(self, value):
|
|
@@ -353,7 +353,7 @@ _PropFunc = Optional[Callable[..., Any]]
|
|
|
353
353
|
_DocType = Optional[str]
|
|
354
354
|
|
|
355
355
|
|
|
356
|
-
class PropertyMapping
|
|
356
|
+
class PropertyMapping:
|
|
357
357
|
def __init__(self):
|
|
358
358
|
self._data: Dict[Tuple[str, _DocType, int], List[_PropFunc]] = {}
|
|
359
359
|
|
|
@@ -393,7 +393,7 @@ class PropertyMapping(object):
|
|
|
393
393
|
yield (name, doc, nargs, fget, fset)
|
|
394
394
|
|
|
395
395
|
|
|
396
|
-
class PropertyGenerator
|
|
396
|
+
class PropertyGenerator:
|
|
397
397
|
def __init__(self, cls_name: str) -> None:
|
|
398
398
|
self._mapping = PropertyMapping()
|
|
399
399
|
self._cls_name = cls_name
|
|
@@ -471,7 +471,7 @@ class DispPropertyGenerator(PropertyGenerator):
|
|
|
471
471
|
return m.name, None, len(m.argspec) - 1
|
|
472
472
|
|
|
473
473
|
|
|
474
|
-
class ComMemberGenerator
|
|
474
|
+
class ComMemberGenerator:
|
|
475
475
|
def __init__(self, cls_name: str, vtbl_offset: int, iid: "comtypes.GUID") -> None:
|
|
476
476
|
self._vtbl_offset = vtbl_offset
|
|
477
477
|
self._iid = iid
|
|
@@ -516,7 +516,7 @@ class ComMemberGenerator(object):
|
|
|
516
516
|
return iter(self._props)
|
|
517
517
|
|
|
518
518
|
|
|
519
|
-
class DispMemberGenerator
|
|
519
|
+
class DispMemberGenerator:
|
|
520
520
|
def __init__(self, cls_name: str) -> None:
|
|
521
521
|
self._props = DispPropertyGenerator(cls_name)
|
|
522
522
|
# sequence of (name: str, func_or_prop: Callable | property, is_prop: bool)
|
|
@@ -606,7 +606,7 @@ class DispMemberGenerator(object):
|
|
|
606
606
|
# Should they be implemented in C for speed?
|
|
607
607
|
|
|
608
608
|
|
|
609
|
-
class bound_named_property
|
|
609
|
+
class bound_named_property:
|
|
610
610
|
def __init__(self, name, fget, fset, instance):
|
|
611
611
|
self.name = name
|
|
612
612
|
self.instance = instance
|
|
@@ -647,7 +647,7 @@ class bound_named_property(object):
|
|
|
647
647
|
raise TypeError(msg)
|
|
648
648
|
|
|
649
649
|
|
|
650
|
-
class named_property
|
|
650
|
+
class named_property:
|
|
651
651
|
def __init__(self, name, fget=None, fset=None, doc=None):
|
|
652
652
|
self.name = name
|
|
653
653
|
self.fget = fget
|
|
@@ -92,27 +92,21 @@ class Interop:
|
|
|
92
92
|
|
|
93
93
|
return self.numpy.dtype(tagVARIANT_format)
|
|
94
94
|
|
|
95
|
-
def
|
|
95
|
+
def _build_typecodes(self):
|
|
96
96
|
if not self.enabled:
|
|
97
97
|
return {}
|
|
98
98
|
import numpy as np
|
|
99
|
-
from numpy import
|
|
99
|
+
from numpy.ctypeslib import as_ctypes_type
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
from numpy.ctypeslib import _typecodes
|
|
103
|
-
except ImportError:
|
|
104
|
-
from numpy.ctypeslib import as_ctypes_type
|
|
101
|
+
dtypes_to_ctypes = {}
|
|
105
102
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
continue
|
|
114
|
-
ctypeslib._typecodes = dtypes_to_ctypes
|
|
115
|
-
return ctypeslib._typecodes
|
|
103
|
+
for tp in set(np.sctypeDict.values()):
|
|
104
|
+
try:
|
|
105
|
+
ctype_for = as_ctypes_type(tp)
|
|
106
|
+
dtypes_to_ctypes[np.dtype(tp).str] = ctype_for
|
|
107
|
+
except NotImplementedError:
|
|
108
|
+
continue
|
|
109
|
+
return dtypes_to_ctypes
|
|
116
110
|
|
|
117
111
|
def isndarray(self, value):
|
|
118
112
|
"""Check if a value is an ndarray.
|
|
@@ -168,7 +162,8 @@ class Interop:
|
|
|
168
162
|
# if that succeeded we can be enabled
|
|
169
163
|
self.enabled = True
|
|
170
164
|
self.VARIANT_dtype = self._make_variant_dtype()
|
|
171
|
-
self.typecodes = self.
|
|
165
|
+
self.typecodes = self._build_typecodes()
|
|
166
|
+
self.datetime64 = self.numpy.datetime64
|
|
172
167
|
self.com_null_date64 = self.numpy.datetime64("1899-12-30T00:00:00", "ns")
|
|
173
168
|
|
|
174
169
|
|
|
@@ -9,7 +9,7 @@ _all_slice = slice(None, None, None)
|
|
|
9
9
|
|
|
10
10
|
def case_insensitive(p: Type) -> None:
|
|
11
11
|
@patcher.Patch(p)
|
|
12
|
-
class CaseInsensitive
|
|
12
|
+
class CaseInsensitive:
|
|
13
13
|
# case insensitive attributes for COM methods and properties
|
|
14
14
|
def __getattr__(self, name):
|
|
15
15
|
"""Implement case insensitive access to methods and properties"""
|
|
@@ -34,7 +34,7 @@ def case_insensitive(p: Type) -> None:
|
|
|
34
34
|
|
|
35
35
|
def reference_fix(pp: Type) -> None:
|
|
36
36
|
@patcher.Patch(pp)
|
|
37
|
-
class ReferenceFix
|
|
37
|
+
class ReferenceFix:
|
|
38
38
|
def __setitem__(self, index, value):
|
|
39
39
|
# We override the __setitem__ method of the
|
|
40
40
|
# POINTER(POINTER(interface)) type, so that the COM
|
|
@@ -64,7 +64,7 @@ def reference_fix(pp: Type) -> None:
|
|
|
64
64
|
|
|
65
65
|
def sized(itf: Type) -> None:
|
|
66
66
|
@patcher.Patch(itf)
|
|
67
|
-
class _
|
|
67
|
+
class _:
|
|
68
68
|
def __len__(self):
|
|
69
69
|
"Return the the 'self.Count' property."
|
|
70
70
|
return self.Count
|
|
@@ -72,7 +72,7 @@ def sized(itf: Type) -> None:
|
|
|
72
72
|
|
|
73
73
|
def callable_and_subscriptable(itf: Type) -> None:
|
|
74
74
|
@patcher.Patch(itf)
|
|
75
|
-
class _
|
|
75
|
+
class _:
|
|
76
76
|
# 'Item' is the 'default' value. Make it available by
|
|
77
77
|
# calling the instance (Not sure this makes sense, but
|
|
78
78
|
# win32com does this also).
|
|
@@ -125,7 +125,7 @@ def callable_and_subscriptable(itf: Type) -> None:
|
|
|
125
125
|
|
|
126
126
|
def iterator(itf: Type) -> None:
|
|
127
127
|
@patcher.Patch(itf)
|
|
128
|
-
class _
|
|
128
|
+
class _:
|
|
129
129
|
def __iter__(self):
|
|
130
130
|
"Return an iterator over the _NewEnum collection."
|
|
131
131
|
# This method returns a pointer to _some_ _NewEnum interface.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from ctypes import HRESULT, POINTER, OleDLL, byref, c_ulong, c_void_p
|
|
2
|
+
from ctypes.wintypes import DWORD, LPVOID
|
|
3
|
+
from typing import TYPE_CHECKING, Optional, Type, TypeVar, overload
|
|
4
|
+
from typing import Union as _UnionT
|
|
5
|
+
|
|
6
|
+
from comtypes import GUID
|
|
7
|
+
from comtypes._post_coinit.unknwn import IUnknown
|
|
8
|
+
from comtypes.GUID import REFCLSID
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from comtypes import hints # type: ignore
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
_T_IUnknown = TypeVar("_T_IUnknown", bound=IUnknown)
|
|
15
|
+
|
|
16
|
+
ACTIVEOBJECT_STRONG = 0x0
|
|
17
|
+
ACTIVEOBJECT_WEAK = 0x1
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def RegisterActiveObject(
|
|
21
|
+
punk: "_UnionT[IUnknown, hints.LP_LP_Vtbl]", clsid: GUID, flags: int
|
|
22
|
+
) -> int:
|
|
23
|
+
"""Registers a pointer as the active object for its class and returns the handle."""
|
|
24
|
+
handle = c_ulong()
|
|
25
|
+
_RegisterActiveObject(punk, byref(clsid), flags, byref(handle))
|
|
26
|
+
return handle.value
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def RevokeActiveObject(handle: int) -> None:
|
|
30
|
+
"""Ends a pointer's status as active."""
|
|
31
|
+
_RevokeActiveObject(handle, None)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@overload
|
|
35
|
+
def GetActiveObject(clsid: GUID, interface: None = None) -> IUnknown: ...
|
|
36
|
+
@overload
|
|
37
|
+
def GetActiveObject(clsid: GUID, interface: Type[_T_IUnknown]) -> _T_IUnknown: ...
|
|
38
|
+
def GetActiveObject(
|
|
39
|
+
clsid: GUID, interface: Optional[Type[IUnknown]] = None
|
|
40
|
+
) -> IUnknown:
|
|
41
|
+
"""Retrieves a pointer to a running object"""
|
|
42
|
+
p = POINTER(IUnknown)()
|
|
43
|
+
_GetActiveObject(byref(clsid), None, byref(p))
|
|
44
|
+
if interface is not None:
|
|
45
|
+
p = p.QueryInterface(interface) # type: ignore
|
|
46
|
+
return p # type: ignore
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
_oleaut32 = OleDLL("oleaut32")
|
|
50
|
+
|
|
51
|
+
_RegisterActiveObject = _oleaut32.RegisterActiveObject
|
|
52
|
+
_RegisterActiveObject.argtypes = [c_void_p, REFCLSID, DWORD, POINTER(DWORD)]
|
|
53
|
+
_RegisterActiveObject.restype = HRESULT
|
|
54
|
+
|
|
55
|
+
_RevokeActiveObject = _oleaut32.RevokeActiveObject
|
|
56
|
+
_RevokeActiveObject.argtypes = [DWORD, LPVOID]
|
|
57
|
+
_RevokeActiveObject.restype = HRESULT
|
|
58
|
+
|
|
59
|
+
_GetActiveObject = _oleaut32.GetActiveObject
|
|
60
|
+
_GetActiveObject.argtypes = [REFCLSID, LPVOID, POINTER(POINTER(IUnknown))]
|
|
61
|
+
_GetActiveObject.restype = HRESULT
|
|
@@ -17,6 +17,7 @@ from typing import TYPE_CHECKING, Any, Callable, Optional, Type, TypeVar, overlo
|
|
|
17
17
|
from comtypes import CLSCTX_LOCAL_SERVER, CLSCTX_REMOTE_SERVER, CLSCTX_SERVER, GUID
|
|
18
18
|
from comtypes._memberspec import COMMETHOD
|
|
19
19
|
from comtypes._post_coinit.unknwn import IUnknown
|
|
20
|
+
from comtypes.GUID import REFCLSID
|
|
20
21
|
|
|
21
22
|
if TYPE_CHECKING:
|
|
22
23
|
from ctypes import _Pointer
|
|
@@ -171,21 +172,6 @@ def CoGetClassObject(clsid, clsctx=None, pServerInfo=None, interface=None):
|
|
|
171
172
|
return p # type: ignore
|
|
172
173
|
|
|
173
174
|
|
|
174
|
-
@overload
|
|
175
|
-
def GetActiveObject(clsid: GUID, interface: None = None) -> IUnknown: ...
|
|
176
|
-
@overload
|
|
177
|
-
def GetActiveObject(clsid: GUID, interface: Type[_T_IUnknown]) -> _T_IUnknown: ...
|
|
178
|
-
def GetActiveObject(
|
|
179
|
-
clsid: GUID, interface: Optional[Type[IUnknown]] = None
|
|
180
|
-
) -> IUnknown:
|
|
181
|
-
"""Retrieves a pointer to a running object"""
|
|
182
|
-
p = POINTER(IUnknown)()
|
|
183
|
-
_GetActiveObject(byref(clsid), None, byref(p))
|
|
184
|
-
if interface is not None:
|
|
185
|
-
p = p.QueryInterface(interface) # type: ignore
|
|
186
|
-
return p # type: ignore
|
|
187
|
-
|
|
188
|
-
|
|
189
175
|
class MULTI_QI(Structure):
|
|
190
176
|
_fields_ = [("pIID", POINTER(GUID)), ("pItf", POINTER(c_void_p)), ("hr", HRESULT)]
|
|
191
177
|
if TYPE_CHECKING:
|
|
@@ -238,14 +224,6 @@ class _COSERVERINFO(Structure):
|
|
|
238
224
|
dwReserved2: int
|
|
239
225
|
|
|
240
226
|
|
|
241
|
-
_oleaut32 = OleDLL("oleaut32")
|
|
242
|
-
|
|
243
|
-
REFCLSID = POINTER(GUID)
|
|
244
|
-
_GetActiveObject = _oleaut32.GetActiveObject
|
|
245
|
-
_GetActiveObject.argtypes = [REFCLSID, LPVOID, POINTER(POINTER(IUnknown))]
|
|
246
|
-
_GetActiveObject.restype = HRESULT
|
|
247
|
-
|
|
248
|
-
|
|
249
227
|
_ole32 = OleDLL("ole32")
|
|
250
228
|
|
|
251
229
|
COSERVERINFO = _COSERVERINFO
|
|
@@ -33,7 +33,7 @@ def _shutdown(
|
|
|
33
33
|
else:
|
|
34
34
|
try:
|
|
35
35
|
func()
|
|
36
|
-
except
|
|
36
|
+
except OSError:
|
|
37
37
|
pass
|
|
38
38
|
# Set the flag which means that calling obj.Release() is no longer
|
|
39
39
|
# needed.
|
|
@@ -287,14 +287,12 @@ class _compointer_base(c_void_p, metaclass=_compointer_meta):
|
|
|
287
287
|
if not isinstance(other, _compointer_base):
|
|
288
288
|
return False
|
|
289
289
|
# get the value property of the c_void_p baseclass, this is the pointer value
|
|
290
|
-
return (
|
|
291
|
-
super(_compointer_base, self).value == super(_compointer_base, other).value
|
|
292
|
-
)
|
|
290
|
+
return super().value == super(_compointer_base, other).value
|
|
293
291
|
|
|
294
292
|
def __hash__(self) -> int:
|
|
295
293
|
"""Return the hash value of the pointer."""
|
|
296
294
|
# hash the pointer values
|
|
297
|
-
return hash(super(
|
|
295
|
+
return hash(super().value)
|
|
298
296
|
|
|
299
297
|
# redefine the .value property; return the object itself.
|
|
300
298
|
def __get_value(self) -> "hints.Self":
|
|
@@ -303,7 +301,7 @@ class _compointer_base(c_void_p, metaclass=_compointer_meta):
|
|
|
303
301
|
value = property(__get_value, doc="""Return self.""")
|
|
304
302
|
|
|
305
303
|
def __repr__(self) -> str:
|
|
306
|
-
ptr = super(
|
|
304
|
+
ptr = super().value
|
|
307
305
|
return f"<{self.__class__.__name__} ptr=0x{ptr or 0:x} at {id(self):x}>"
|
|
308
306
|
|
|
309
307
|
# This fixes the problem when there are multiple python interface types
|
|
@@ -93,7 +93,7 @@ def catch_errors(
|
|
|
93
93
|
except comtypes.ReturnHRESULT as err:
|
|
94
94
|
(hr, text) = err.args
|
|
95
95
|
return ReportError(text, iid=interface._iid_, clsid=clsid, hresult=hr)
|
|
96
|
-
except (
|
|
96
|
+
except (OSError, COMError) as details:
|
|
97
97
|
_error(
|
|
98
98
|
"Exception in %s.%s implementation:",
|
|
99
99
|
interface.__name__,
|
|
@@ -201,7 +201,7 @@ def hack(
|
|
|
201
201
|
msg = f"{source}: {descr}"
|
|
202
202
|
hr = HRESULT_FROM_WIN32(hr)
|
|
203
203
|
return ReportError(msg, iid=interface._iid_, clsid=clsid, hresult=hr)
|
|
204
|
-
except
|
|
204
|
+
except OSError as details:
|
|
205
205
|
_error(
|
|
206
206
|
"Exception in %s.%s implementation:",
|
|
207
207
|
interface.__name__,
|
|
@@ -228,7 +228,7 @@ def hack(
|
|
|
228
228
|
return call_without_this
|
|
229
229
|
|
|
230
230
|
|
|
231
|
-
class _MethodFinder
|
|
231
|
+
class _MethodFinder:
|
|
232
232
|
def __init__(self, inst: "hints.COMObject") -> None:
|
|
233
233
|
self.inst = inst
|
|
234
234
|
# map lower case names to names with correct spelling.
|
|
@@ -245,9 +245,6 @@ class tagVARIANT(Structure):
|
|
|
245
245
|
elif isinstance(value, bool):
|
|
246
246
|
self.vt = VT_BOOL
|
|
247
247
|
self._.VT_BOOL = value
|
|
248
|
-
elif isinstance(value, (int, c_int)):
|
|
249
|
-
self.vt = VT_I4
|
|
250
|
-
self._.VT_I4 = value
|
|
251
248
|
elif isinstance(value, int):
|
|
252
249
|
u = self._
|
|
253
250
|
# try VT_I4 first.
|
|
@@ -264,12 +261,11 @@ class tagVARIANT(Structure):
|
|
|
264
261
|
self.vt = VT_UI4
|
|
265
262
|
return
|
|
266
263
|
# try VT_I8 next.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
return
|
|
264
|
+
u.VT_I8 = value
|
|
265
|
+
if u.VT_I8 == value:
|
|
266
|
+
# did work.
|
|
267
|
+
self.vt = VT_I8
|
|
268
|
+
return
|
|
273
269
|
# try VT_UI8 next.
|
|
274
270
|
if value >= 0:
|
|
275
271
|
u.VT_UI8 = value
|
|
@@ -277,9 +273,7 @@ class tagVARIANT(Structure):
|
|
|
277
273
|
# did work.
|
|
278
274
|
self.vt = VT_UI8
|
|
279
275
|
return
|
|
280
|
-
|
|
281
|
-
self.vt = VT_R8
|
|
282
|
-
u.VT_R8 = float(value)
|
|
276
|
+
raise TypeError(f"Cannot put {value!r} in VARIANT")
|
|
283
277
|
elif isinstance(value, (float, c_double)):
|
|
284
278
|
self.vt = VT_R8
|
|
285
279
|
self._.VT_R8 = value
|
|
@@ -364,6 +358,9 @@ class tagVARIANT(Structure):
|
|
|
364
358
|
elif isinstance(value, c_uint):
|
|
365
359
|
self.vt = VT_UI4
|
|
366
360
|
self._.VT_UI4 = value
|
|
361
|
+
elif isinstance(value, c_int):
|
|
362
|
+
self.vt = VT_I4
|
|
363
|
+
self._.VT_I4 = value
|
|
367
364
|
elif isinstance(value, c_float):
|
|
368
365
|
self.vt = VT_R4
|
|
369
366
|
self._.VT_R4 = value
|
|
@@ -608,7 +605,7 @@ del v
|
|
|
608
605
|
|
|
609
606
|
|
|
610
607
|
@comtypes.patcher.Patch(POINTER(VARIANT))
|
|
611
|
-
class _
|
|
608
|
+
class _:
|
|
612
609
|
# Override the default .from_param classmethod of POINTER(VARIANT).
|
|
613
610
|
# This allows to pass values which can be stored in VARIANTs as
|
|
614
611
|
# function parameters declared as POINTER(VARIANT). See
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
import ctypes
|
|
4
4
|
import logging
|
|
5
5
|
|
|
6
|
-
from comtypes import automation
|
|
6
|
+
from comtypes import RevokeActiveObject, automation # noqa
|
|
7
7
|
from comtypes.client import dynamic, lazybind # noqa
|
|
8
|
+
from comtypes.client._activeobj import RegisterActiveObject # noqa
|
|
8
9
|
from comtypes.client._code_cache import _find_gen_dir
|
|
9
10
|
from comtypes.client._constants import Constants # noqa
|
|
10
11
|
from comtypes.client._events import GetEvents, PumpEvents, ShowEvents
|
|
@@ -44,3 +44,11 @@ def GetActiveObject(
|
|
|
44
44
|
if dynamic:
|
|
45
45
|
return comtypes.client.dynamic.Dispatch(obj)
|
|
46
46
|
return _manage(obj, clsid, interface=interface)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def RegisterActiveObject(
|
|
50
|
+
punk: IUnknown, progid: _UnionT[str, Type[CoClass], GUID], weak: bool = True
|
|
51
|
+
) -> int:
|
|
52
|
+
clsid = GUID.from_progid(progid)
|
|
53
|
+
flags = comtypes.ACTIVEOBJECT_WEAK if weak else comtypes.ACTIVEOBJECT_STRONG
|
|
54
|
+
return comtypes.RegisterActiveObject(punk, clsid, flags)
|
|
@@ -115,7 +115,7 @@ def _create_comtypes_gen_package():
|
|
|
115
115
|
ofi = open(comtypes_init, "w")
|
|
116
116
|
ofi.write("# comtypes.gen package, directory for generated files.\n")
|
|
117
117
|
ofi.close()
|
|
118
|
-
except
|
|
118
|
+
except OSError as details:
|
|
119
119
|
logger.info("Creating comtypes.gen package failed: %s", details)
|
|
120
120
|
module = sys.modules["comtypes.gen"] = types.ModuleType("comtypes.gen")
|
|
121
121
|
comtypes.gen = module
|
|
@@ -64,7 +64,7 @@ _CloseHandle.restype = BOOL
|
|
|
64
64
|
_ReceiverType = _UnionT[COMObject, IUnknown]
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
class _AdviseConnection
|
|
67
|
+
class _AdviseConnection:
|
|
68
68
|
cp: Optional[IConnectionPoint]
|
|
69
69
|
cookie: Optional[int]
|
|
70
70
|
receiver: Optional[_ReceiverType]
|
|
@@ -104,7 +104,7 @@ class _AdviseConnection(object):
|
|
|
104
104
|
if self.cookie is not None:
|
|
105
105
|
assert self.cp is not None
|
|
106
106
|
self.cp.Unadvise(self.cookie)
|
|
107
|
-
except (
|
|
107
|
+
except (OSError, COMError):
|
|
108
108
|
# Are we sure we want to ignore errors here?
|
|
109
109
|
pass
|
|
110
110
|
|
|
@@ -209,7 +209,7 @@ class _SinkMethodFinder(_MethodFinder):
|
|
|
209
209
|
"""
|
|
210
210
|
|
|
211
211
|
def __init__(self, inst: COMObject, sink: Any) -> None:
|
|
212
|
-
super(
|
|
212
|
+
super().__init__(inst)
|
|
213
213
|
self.sink = sink
|
|
214
214
|
|
|
215
215
|
def find_method(self, fq_name: str, mthname: str) -> Callable[..., Any]:
|
|
@@ -229,7 +229,7 @@ class _SinkMethodFinder(_MethodFinder):
|
|
|
229
229
|
|
|
230
230
|
def _find_method(self, fq_name: str, mthname: str) -> Callable[..., Any]:
|
|
231
231
|
try:
|
|
232
|
-
return super(
|
|
232
|
+
return super().find_method(fq_name, mthname)
|
|
233
233
|
except AttributeError:
|
|
234
234
|
try:
|
|
235
235
|
return getattr(self.sink, fq_name)
|
|
@@ -283,7 +283,7 @@ def GetEvents(
|
|
|
283
283
|
return _AdviseConnection(source, interface, rcv)
|
|
284
284
|
|
|
285
285
|
|
|
286
|
-
class EventDumper
|
|
286
|
+
class EventDumper:
|
|
287
287
|
"""Universal sink for COM events."""
|
|
288
288
|
|
|
289
289
|
def __getattr__(self, name: str) -> Callable[..., Any]:
|
|
@@ -381,7 +381,7 @@ def PumpEvents(timeout: Any) -> None:
|
|
|
381
381
|
handles,
|
|
382
382
|
byref(ctypes.c_ulong()),
|
|
383
383
|
)
|
|
384
|
-
except
|
|
384
|
+
except OSError as details:
|
|
385
385
|
if details.winerror != hresult.RPC_S_CALLPENDING: # timeout expired
|
|
386
386
|
raise
|
|
387
387
|
else:
|
|
@@ -211,7 +211,7 @@ def _create_module(modulename: str, code: str) -> types.ModuleType:
|
|
|
211
211
|
return _my_import(modulename)
|
|
212
212
|
|
|
213
213
|
|
|
214
|
-
class ModuleGenerator
|
|
214
|
+
class ModuleGenerator:
|
|
215
215
|
def __init__(self, tlib: typeinfo.ITypeLib, pathname: Optional[str]) -> None:
|
|
216
216
|
self.wrapper_name = codegenerator.name_wrapper_module(tlib)
|
|
217
217
|
self.friendly_name = codegenerator.name_friendly_module(tlib)
|
|
@@ -27,7 +27,7 @@ def Dispatch(obj):
|
|
|
27
27
|
if isinstance(obj, ctypes.POINTER(automation.IDispatch)):
|
|
28
28
|
try:
|
|
29
29
|
tinfo = obj.GetTypeInfo(0)
|
|
30
|
-
except (
|
|
30
|
+
except (OSError, COMError):
|
|
31
31
|
return _Dispatch(obj)
|
|
32
32
|
return lazybind.Dispatch(obj, tinfo)
|
|
33
33
|
return obj
|
|
@@ -59,7 +59,7 @@ class MethodCaller:
|
|
|
59
59
|
)
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
class _Dispatch
|
|
62
|
+
class _Dispatch:
|
|
63
63
|
"""Expose methods and properties via fully dynamic dispatch."""
|
|
64
64
|
|
|
65
65
|
_comobj: automation.IDispatch
|
|
@@ -160,7 +160,7 @@ class _Dispatch(object):
|
|
|
160
160
|
# )
|
|
161
161
|
|
|
162
162
|
|
|
163
|
-
class _Collection
|
|
163
|
+
class _Collection:
|
|
164
164
|
def __init__(self, enum: automation.IEnumVARIANT):
|
|
165
165
|
self.enum = enum
|
|
166
166
|
|