comtypes 1.4.11__zip → 1.4.13__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.
Files changed (151) hide show
  1. {comtypes-1.4.11 → comtypes-1.4.13}/CHANGES.txt +33 -0
  2. {comtypes-1.4.11/comtypes.egg-info → comtypes-1.4.13}/PKG-INFO +5 -5
  3. {comtypes-1.4.11 → comtypes-1.4.13}/README.md +3 -3
  4. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/__init__.py +8 -2
  5. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/_comobject.py +6 -6
  6. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/_memberspec.py +7 -7
  7. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/_meta.py +7 -3
  8. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/_npsupport.py +12 -17
  9. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/_post_coinit/_cominterface_meta_patcher.py +5 -5
  10. comtypes-1.4.13/comtypes/_post_coinit/activeobj.py +61 -0
  11. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/_post_coinit/misc.py +1 -23
  12. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/_post_coinit/unknwn.py +10 -8
  13. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/_vtbl.py +3 -3
  14. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/automation.py +10 -13
  15. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/client/__init__.py +2 -1
  16. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/client/_activeobj.py +8 -0
  17. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/client/_code_cache.py +1 -1
  18. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/client/_constants.py +1 -1
  19. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/client/_events.py +6 -6
  20. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/client/_generate.py +1 -1
  21. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/client/dynamic.py +3 -3
  22. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/client/lazybind.py +3 -3
  23. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/errorinfo.py +1 -1
  24. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/hresult.py +68 -0
  25. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/messageloop.py +1 -1
  26. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/patcher.py +2 -2
  27. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/persist.py +9 -2
  28. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/safearray.py +10 -10
  29. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/server/__init__.py +5 -37
  30. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/server/automation.py +2 -2
  31. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/server/connectionpoints.py +3 -3
  32. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/server/inprocserver.py +2 -2
  33. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/server/localserver.py +3 -3
  34. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/server/register.py +5 -5
  35. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_agilent.py +1 -1
  36. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_client_dynamic.py +1 -1
  37. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_comserver.py +15 -2
  38. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_createwrappers.py +1 -1
  39. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_dispifc_records.py +0 -2
  40. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_dispifc_safearrays.py +0 -2
  41. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_dispinterface.py +1 -1
  42. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_excel.py +2 -5
  43. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_getactiveobj.py +19 -2
  44. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_hresult.py +39 -0
  45. comtypes-1.4.13/comtypes/test/test_messageloop.py +117 -0
  46. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_midl_safearray_create.py +0 -2
  47. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_msscript.py +1 -1
  48. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_npsupport.py +22 -11
  49. comtypes-1.4.13/comtypes/test/test_persist.py +71 -0
  50. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_recordinfo.py +0 -2
  51. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_server.py +6 -6
  52. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_storage.py +1 -1
  53. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_stream.py +22 -2
  54. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_urlhistory.py +1 -1
  55. comtypes-1.4.13/comtypes/test/test_util.py +227 -0
  56. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_variant.py +41 -24
  57. comtypes-1.4.13/comtypes/test/test_viewobject.py +78 -0
  58. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_word.py +1 -1
  59. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/tools/codegenerator/codegenerator.py +1 -1
  60. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/tools/codegenerator/comments.py +1 -1
  61. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/tools/codegenerator/heads.py +5 -5
  62. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/tools/codegenerator/helpers.py +7 -7
  63. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/tools/codegenerator/namespaces.py +3 -3
  64. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/tools/codegenerator/typeannotator.py +2 -2
  65. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/tools/tlbparser.py +1 -1
  66. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/tools/typedesc.py +14 -14
  67. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/tools/typedesc_base.py +19 -19
  68. comtypes-1.4.13/comtypes/util.py +189 -0
  69. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/viewobject.py +29 -5
  70. {comtypes-1.4.11 → comtypes-1.4.13/comtypes.egg-info}/PKG-INFO +5 -5
  71. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes.egg-info/SOURCES.txt +4 -0
  72. {comtypes-1.4.11 → comtypes-1.4.13}/pyproject.toml +12 -1
  73. {comtypes-1.4.11 → comtypes-1.4.13}/setup.cfg +1 -1
  74. comtypes-1.4.11/comtypes/test/test_persist.py +0 -38
  75. comtypes-1.4.11/comtypes/util.py +0 -107
  76. {comtypes-1.4.11 → comtypes-1.4.13}/LICENSE.txt +0 -0
  77. {comtypes-1.4.11 → comtypes-1.4.13}/MANIFEST.in +0 -0
  78. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/GUID.py +0 -0
  79. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/_post_coinit/__init__.py +0 -0
  80. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/_post_coinit/bstr.py +0 -0
  81. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/_post_coinit/instancemethod.py +0 -0
  82. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/_safearray.py +0 -0
  83. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/_tlib_version_checker.py +0 -0
  84. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/clear_cache.py +0 -0
  85. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/client/_create.py +0 -0
  86. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/client/_managing.py +0 -0
  87. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/connectionpoints.py +0 -0
  88. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/git.py +0 -0
  89. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/hints.pyi +0 -0
  90. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/logutil.py +0 -0
  91. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/server/w_getopt.py +0 -0
  92. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/shelllink.py +0 -0
  93. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/stream.py +0 -0
  94. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/TestComServer.idl +0 -0
  95. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/TestComServer.py +0 -0
  96. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/TestComServer.tlb +0 -0
  97. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/TestDispServer.idl +0 -0
  98. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/TestDispServer.py +0 -0
  99. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/TestDispServer.tlb +0 -0
  100. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/__init__.py +0 -0
  101. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/find_memleak.py +0 -0
  102. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/mylib.idl +0 -0
  103. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/mylib.tlb +0 -0
  104. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/mytypelib.idl +0 -0
  105. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/runtests.py +0 -0
  106. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/setup.py +0 -0
  107. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_BSTR.py +0 -0
  108. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_DISPPARAMS.py +0 -0
  109. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_GUID.py +0 -0
  110. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_QueryService.py +0 -0
  111. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_avmc.py +0 -0
  112. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_basic.py +0 -0
  113. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_casesensitivity.py +0 -0
  114. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_clear_cache.py +0 -0
  115. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_client.py +0 -0
  116. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_client_regenerate_modules.py +0 -0
  117. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_collections.py +0 -0
  118. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_comobject.py +0 -0
  119. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_dict.py +0 -0
  120. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_dyndispatch.py +0 -0
  121. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_errorinfo.py +0 -0
  122. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_findgendir.py +0 -0
  123. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_ie.py +0 -0
  124. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_ienum.py +0 -0
  125. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_imfattributes.py +0 -0
  126. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_inout_args.py +0 -0
  127. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_jscript.js +0 -0
  128. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_monikers.py +0 -0
  129. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_outparam.py +0 -0
  130. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_pump_events.py +0 -0
  131. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_safearray.py +0 -0
  132. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_sapi.py +0 -0
  133. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_server_register.py +0 -0
  134. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_shelllink.py +0 -0
  135. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_showevents.py +0 -0
  136. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_subinterface.py +0 -0
  137. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_typeannotator.py +0 -0
  138. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_typeinfo.py +0 -0
  139. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_w_getopt.py +0 -0
  140. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_win32com_interop.py +0 -0
  141. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/test_wmi.py +0 -0
  142. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/test/urlhist.tlb +0 -0
  143. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/tools/__init__.py +0 -0
  144. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/tools/codegenerator/__init__.py +0 -0
  145. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/tools/codegenerator/modulenamer.py +0 -0
  146. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/tools/codegenerator/packing.py +0 -0
  147. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes/typeinfo.py +0 -0
  148. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes.egg-info/dependency_links.txt +0 -0
  149. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes.egg-info/entry_points.txt +0 -0
  150. {comtypes-1.4.11 → comtypes-1.4.13}/comtypes.egg-info/top_level.txt +0 -0
  151. {comtypes-1.4.11 → comtypes-1.4.13}/setup.py +0 -0
@@ -1,6 +1,39 @@
1
1
  Comtypes CHANGELOG
2
2
  ==================
3
3
 
4
+ Release 1.4.13
5
+ --------------
6
+ * Remove Python 3.8 and add Python 3.14 to the CI pipelines. By @junkmd.
7
+ * Declare the minimum Python version as 3.9. By @junkmd. By @junkmd.
8
+ * Update ``PyCArgObject.value`` for Python 3.14 compatibility. By @junkmd.
9
+ * Add version bridges for the ``__pointer_type__`` attribute protocol. By @junkmd.
10
+
11
+ Release 1.4.12
12
+ --------------
13
+ * Add support for coverage. By @moi15moi.
14
+ * CI/CD Improvements for runners and the codecov badge. By @junkmd.
15
+ * Add signed 32-bit hexadecimal converters. By @junkmd.
16
+ * Add ``Test_Stat`` to ``test_stream``. By @junkmd.
17
+ * Add client-side ``RegisterActiveObject``. By @junkmd.
18
+ * Remove useless ``object`` inheritance from every class. By @moi15moi.
19
+ * Modernize ``super()`` calls by removing explicit class and instance arguments. By @moi15moi.
20
+ * Eliminate outdated encoding boilerplates. By @moi15moi.
21
+ * Update byte string creation to use ``b""`` instead of ``str.encode("utf-8")``. By @moi15moi.
22
+ * Introduce ``codecov.yml``. By @moi15moi.
23
+ * Migrate exception catches from older aliases to ``OSError``. By @moi15moi.
24
+ * Remove obsolete Python 2 compatibility code in ``test_variant``. By @junkmd.
25
+ * Skip ``test_eval`` in INPROC server tests due to instability. By @junkmd.
26
+ * Adjust structure sizes and alignments for 64-bit Python in ``viewobject.py``. By @junkmd.
27
+ * Add ``test_viewobject``. By @junkmd.
28
+ * Ensure ``test_npsupport`` passes with ``numpy>=2.0.0`` by explicitly setting ``dtype=numpy.int32``. By @junkmd.
29
+ * Add tests for ``DictPropertyBag`` and type hints for ``IPropertyBag``. By @junkmd.
30
+ * Fix ``numpy`` interoperability and enable ``datetime64`` tests. By @junkmd.
31
+ * Revive and correct integer handling logic for ``VARIANT``s when setting values. By @junkmd.
32
+ * Add tests for ``messageloop``. By @junkmd.
33
+ * Revive ``util`` and add comprehensive tests. By @junkmd.
34
+ * Refactor and enhance ``util`` with explicit imports and typing. By @junkmd.
35
+ * Modernize ``npsupport`` by removing the patch for the ``np._typecodes``. By @junkmd.
36
+
4
37
  Release 1.4.11
5
38
  --------------
6
39
  * 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.11
3
+ Version: 1.4.13
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
@@ -13,7 +13,7 @@ Classifier: Operating System :: Microsoft :: Windows
13
13
  Classifier: Programming Language :: Python
14
14
  Classifier: Programming Language :: Python :: 3
15
15
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
- Requires-Python: >=3.8
16
+ Requires-Python: >=3.9
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE.txt
19
19
  Dynamic: download-url
@@ -25,18 +25,18 @@ Dynamic: license-file
25
25
  [![PyPI version](https://badge.fury.io/py/comtypes.svg)](https://pypi.org/project/comtypes/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/comtypes)](https://pypi.org/project/comtypes/) [![PyPI - Python Requires](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fpypi.org%2Fpypi%2Fcomtypes%2Fjson&query=info.requires_python&label=Python Requires)](https://pypi.org/project/comtypes/)
26
26
  [![PyPI - License](https://img.shields.io/pypi/l/comtypes)](https://pypi.org/project/comtypes/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/comtypes)](https://pypi.org/project/comtypes/)
27
27
  [![GitHub Repo stars](https://img.shields.io/github/stars/enthought/comtypes?style=social)](https://github.com/enthought/comtypes/stargazers) [![GitHub forks](https://img.shields.io/github/forks/enthought/comtypes?style=social)](https://github.com/enthought/comtypes/network/members) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
28
- [![Tidelift Subscription](https://tidelift.com/badges/package/pypi/comtypes)](https://tidelift.com/subscription/pkg/pypi-comtypes?utm_source=pypi-comtypes&utm_medium=readme)
28
+ [![Tidelift Subscription](https://tidelift.com/badges/package/pypi/comtypes)](https://tidelift.com/subscription/pkg/pypi-comtypes?utm_source=pypi-comtypes&utm_medium=readme) [![Coverage](https://img.shields.io/codecov/c/github/enthought/comtypes)](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.
32
32
 
33
33
  `comtypes` allows you to define, call, and implement custom and dispatch-based COM interfaces in pure Python.
34
34
 
35
- `comtypes` requires Windows and Python 3.8 or later.
35
+ `comtypes` requires Windows and Python 3.9 or later.
36
+ - Version [1.4.12](https://pypi.org/project/comtypes/1.4.12/) is the last version to support Python 3.8.
36
37
  - Version <= [1.4.7](https://pypi.org/project/comtypes/1.4.7/) does not work with Python 3.13 as reported in [GH-618](https://github.com/enthought/comtypes/issues/618). Version [1.4.8](https://pypi.org/project/comtypes/1.4.8/) can work with Python 3.13.
37
38
  - Version [1.4.6](https://pypi.org/project/comtypes/1.4.6/) is the last version to support Python 3.7.
38
39
  - Version [1.2.1](https://pypi.org/project/comtypes/1.2.1/) is the last version to support Python 2.7 and 3.3–3.6.
39
- - `comtypes` does not work with Python 3.8.1 as reported in [GH-202](https://github.com/enthought/comtypes/issues/202). This bug has been fixed in Python >= 3.8.2.
40
40
  - Certain `comtypes` functions may not work correctly in Python 3.8 and 3.9 as reported in [GH-212](https://github.com/enthought/comtypes/issues/212). This bug has been fixed in Python >= 3.10.10 and >= 3.11.2.
41
41
 
42
42
  ## Installation
@@ -4,18 +4,18 @@
4
4
  [![PyPI version](https://badge.fury.io/py/comtypes.svg)](https://pypi.org/project/comtypes/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/comtypes)](https://pypi.org/project/comtypes/) [![PyPI - Python Requires](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fpypi.org%2Fpypi%2Fcomtypes%2Fjson&query=info.requires_python&label=Python&nbsp;Requires)](https://pypi.org/project/comtypes/)
5
5
  [![PyPI - License](https://img.shields.io/pypi/l/comtypes)](https://pypi.org/project/comtypes/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/comtypes)](https://pypi.org/project/comtypes/)
6
6
  [![GitHub Repo stars](https://img.shields.io/github/stars/enthought/comtypes?style=social)](https://github.com/enthought/comtypes/stargazers) [![GitHub forks](https://img.shields.io/github/forks/enthought/comtypes?style=social)](https://github.com/enthought/comtypes/network/members) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
7
- [![Tidelift Subscription](https://tidelift.com/badges/package/pypi/comtypes)](https://tidelift.com/subscription/pkg/pypi-comtypes?utm_source=pypi-comtypes&utm_medium=readme)
7
+ [![Tidelift Subscription](https://tidelift.com/badges/package/pypi/comtypes)](https://tidelift.com/subscription/pkg/pypi-comtypes?utm_source=pypi-comtypes&utm_medium=readme) [![Coverage](https://img.shields.io/codecov/c/github/enthought/comtypes)](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.
11
11
 
12
12
  `comtypes` allows you to define, call, and implement custom and dispatch-based COM interfaces in pure Python.
13
13
 
14
- `comtypes` requires Windows and Python 3.8 or later.
14
+ `comtypes` requires Windows and Python 3.9 or later.
15
+ - Version [1.4.12](https://pypi.org/project/comtypes/1.4.12/) is the last version to support Python 3.8.
15
16
  - Version <= [1.4.7](https://pypi.org/project/comtypes/1.4.7/) does not work with Python 3.13 as reported in [GH-618](https://github.com/enthought/comtypes/issues/618). Version [1.4.8](https://pypi.org/project/comtypes/1.4.8/) can work with Python 3.13.
16
17
  - Version [1.4.6](https://pypi.org/project/comtypes/1.4.6/) is the last version to support Python 3.7.
17
18
  - Version [1.2.1](https://pypi.org/project/comtypes/1.2.1/) is the last version to support Python 2.7 and 3.3–3.6.
18
- - `comtypes` does not work with Python 3.8.1 as reported in [GH-202](https://github.com/enthought/comtypes/issues/202). This bug has been fixed in Python >= 3.8.2.
19
19
  - Certain `comtypes` functions may not work correctly in Python 3.8 and 3.9 as reported in [GH-212](https://github.com/enthought/comtypes/issues/212). This bug has been fixed in Python >= 3.10.10 and >= 3.11.2.
20
20
 
21
21
  ## Installation
@@ -1,5 +1,5 @@
1
1
  # comtypes version numbers follow semver (http://semver.org/) and PEP 440
2
- __version__ = "1.4.11"
2
+ __version__ = "1.4.13"
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(object):
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(object):
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(object):
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(COMObject, cls).__new__(cls)
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 WindowsError(hresult.E_NOTIMPL)
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 WindowsError(hresult.E_INVALIDARG)
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(object):
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(object):
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(object):
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(object):
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(object):
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(object):
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(object):
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
@@ -1,4 +1,5 @@
1
1
  # comtypes._meta helper module
2
+ import sys
2
3
  from ctypes import POINTER, c_void_p, cast
3
4
 
4
5
  import comtypes
@@ -74,7 +75,7 @@ class _coclass_meta(type):
74
75
  # Depending on a version or revision of Python, this may be essential.
75
76
  return self
76
77
 
77
- PTR = _coclass_pointer_meta(
78
+ p = _coclass_pointer_meta(
78
79
  f"POINTER({self.__name__})",
79
80
  (self, c_void_p),
80
81
  {
@@ -82,9 +83,12 @@ class _coclass_meta(type):
82
83
  "from_param": classmethod(_coclass_from_param),
83
84
  },
84
85
  )
85
- from ctypes import _pointer_type_cache # type: ignore
86
+ if sys.version_info >= (3, 14):
87
+ self.__pointer_type__ = p
88
+ else:
89
+ from ctypes import _pointer_type_cache # type: ignore
86
90
 
87
- _pointer_type_cache[self] = PTR
91
+ _pointer_type_cache[self] = p
88
92
 
89
93
  return self
90
94
 
@@ -92,27 +92,21 @@ class Interop:
92
92
 
93
93
  return self.numpy.dtype(tagVARIANT_format)
94
94
 
95
- def _check_ctypeslib_typecodes(self):
95
+ def _build_typecodes(self):
96
96
  if not self.enabled:
97
97
  return {}
98
98
  import numpy as np
99
- from numpy import ctypeslib
99
+ from numpy.ctypeslib import as_ctypes_type
100
100
 
101
- try:
102
- from numpy.ctypeslib import _typecodes
103
- except ImportError:
104
- from numpy.ctypeslib import as_ctypes_type
101
+ dtypes_to_ctypes = {}
105
102
 
106
- dtypes_to_ctypes = {}
107
-
108
- for tp in set(np.sctypeDict.values()):
109
- try:
110
- ctype_for = as_ctypes_type(tp)
111
- dtypes_to_ctypes[np.dtype(tp).str] = ctype_for
112
- except NotImplementedError:
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._check_ctypeslib_typecodes()
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(object):
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(object):
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 _(object):
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 _(object):
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 _(object):
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
@@ -1,6 +1,7 @@
1
1
  # https://learn.microsoft.com/en-us/windows/win32/api/unknwn/
2
2
 
3
3
  import logging
4
+ import sys
4
5
  from ctypes import HRESULT, POINTER, byref, c_ulong, c_void_p
5
6
  from typing import TYPE_CHECKING, Any, ClassVar, List, Optional, Type, TypeVar
6
7
 
@@ -33,7 +34,7 @@ def _shutdown(
33
34
  else:
34
35
  try:
35
36
  func()
36
- except WindowsError:
37
+ except OSError:
37
38
  pass
38
39
  # Set the flag which means that calling obj.Release() is no longer
39
40
  # needed.
@@ -126,9 +127,12 @@ class _cominterface_meta(type):
126
127
  {"__com_interface__": self, "_needs_com_addref_": None},
127
128
  )
128
129
 
129
- from ctypes import _pointer_type_cache # type: ignore
130
+ if sys.version_info >= (3, 14):
131
+ self.__pointer_type__ = p
132
+ else:
133
+ from ctypes import _pointer_type_cache # type: ignore
130
134
 
131
- _pointer_type_cache[self] = p
135
+ _pointer_type_cache[self] = p
132
136
 
133
137
  if self._case_insensitive_:
134
138
  _meta_patch.case_insensitive(p)
@@ -287,14 +291,12 @@ class _compointer_base(c_void_p, metaclass=_compointer_meta):
287
291
  if not isinstance(other, _compointer_base):
288
292
  return False
289
293
  # 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
- )
294
+ return super().value == super(_compointer_base, other).value
293
295
 
294
296
  def __hash__(self) -> int:
295
297
  """Return the hash value of the pointer."""
296
298
  # hash the pointer values
297
- return hash(super(_compointer_base, self).value)
299
+ return hash(super().value)
298
300
 
299
301
  # redefine the .value property; return the object itself.
300
302
  def __get_value(self) -> "hints.Self":
@@ -303,7 +305,7 @@ class _compointer_base(c_void_p, metaclass=_compointer_meta):
303
305
  value = property(__get_value, doc="""Return self.""")
304
306
 
305
307
  def __repr__(self) -> str:
306
- ptr = super(_compointer_base, self).value
308
+ ptr = super().value
307
309
  return f"<{self.__class__.__name__} ptr=0x{ptr or 0:x} at {id(self):x}>"
308
310
 
309
311
  # 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 (COMError, WindowsError) as details:
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 WindowsError as details:
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(object):
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
- if value >= 0:
268
- u.VT_I8 = value
269
- if u.VT_I8 == value:
270
- # did work.
271
- self.vt = VT_I8
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
- # VT_R8 is last resort.
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 _(object):
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 (OSError, IOError) as details:
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