comtypes 1.4.9__zip → 1.4.11__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 (148) hide show
  1. {comtypes-1.4.9 → comtypes-1.4.11}/CHANGES.txt +41 -0
  2. {comtypes-1.4.9/comtypes.egg-info → comtypes-1.4.11}/PKG-INFO +4 -2
  3. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/GUID.py +34 -13
  4. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/__init__.py +25 -16
  5. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_comobject.py +92 -39
  6. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_memberspec.py +112 -78
  7. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_meta.py +2 -1
  8. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_post_coinit/_cominterface_meta_patcher.py +3 -6
  9. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_post_coinit/bstr.py +12 -5
  10. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_post_coinit/instancemethod.py +1 -2
  11. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_post_coinit/misc.py +59 -24
  12. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_post_coinit/unknwn.py +30 -25
  13. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_safearray.py +2 -2
  14. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_vtbl.py +52 -55
  15. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/automation.py +19 -14
  16. comtypes-1.4.11/comtypes/client/__init__.py +42 -0
  17. comtypes-1.4.11/comtypes/client/_activeobj.py +46 -0
  18. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/client/_code_cache.py +15 -24
  19. comtypes-1.4.11/comtypes/client/_create.py +147 -0
  20. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/client/_events.py +140 -57
  21. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/client/_generate.py +3 -5
  22. comtypes-1.4.11/comtypes/client/_managing.py +114 -0
  23. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/client/dynamic.py +2 -3
  24. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/client/lazybind.py +10 -11
  25. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/connectionpoints.py +38 -3
  26. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/errorinfo.py +72 -21
  27. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/git.py +4 -3
  28. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/hints.pyi +15 -2
  29. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/hresult.py +16 -6
  30. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/logutil.py +15 -3
  31. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/messageloop.py +15 -13
  32. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/persist.py +3 -5
  33. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/safearray.py +8 -6
  34. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/server/__init__.py +22 -4
  35. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/server/automation.py +1 -2
  36. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/server/connectionpoints.py +71 -70
  37. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/server/inprocserver.py +14 -8
  38. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/server/localserver.py +28 -16
  39. comtypes-1.4.11/comtypes/server/register.py +478 -0
  40. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/shelllink.py +13 -7
  41. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/stream.py +7 -4
  42. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/TestComServer.py +6 -7
  43. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/TestDispServer.py +4 -2
  44. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/__init__.py +1 -1
  45. comtypes-1.4.11/comtypes/test/find_memleak.py +72 -0
  46. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/runtests.py +1 -0
  47. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/setup.py +2 -1
  48. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_BSTR.py +7 -17
  49. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_GUID.py +7 -7
  50. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_QueryService.py +1 -0
  51. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_agilent.py +4 -3
  52. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_basic.py +18 -9
  53. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_clear_cache.py +1 -1
  54. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_client.py +2 -2
  55. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_client_dynamic.py +2 -2
  56. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_client_regenerate_modules.py +2 -2
  57. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_collections.py +7 -4
  58. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_comobject.py +22 -9
  59. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_comserver.py +56 -3
  60. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_dict.py +2 -1
  61. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_dispifc_records.py +1 -1
  62. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_dispifc_safearrays.py +1 -1
  63. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_dyndispatch.py +5 -2
  64. comtypes-1.4.11/comtypes/test/test_errorinfo.py +115 -0
  65. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_findgendir.py +1 -2
  66. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_getactiveobj.py +4 -4
  67. comtypes-1.4.11/comtypes/test/test_hresult.py +48 -0
  68. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_ie.py +19 -6
  69. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_ienum.py +2 -2
  70. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_imfattributes.py +13 -3
  71. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_inout_args.py +10 -3
  72. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_midl_safearray_create.py +6 -4
  73. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_monikers.py +23 -9
  74. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_msscript.py +2 -1
  75. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_npsupport.py +4 -4
  76. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_outparam.py +22 -6
  77. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_persist.py +2 -4
  78. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_recordinfo.py +1 -1
  79. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_safearray.py +2 -1
  80. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_sapi.py +4 -1
  81. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_server_register.py +114 -125
  82. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_shelllink.py +2 -3
  83. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_storage.py +12 -6
  84. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_stream.py +16 -5
  85. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_subinterface.py +4 -2
  86. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_typeannotator.py +1 -2
  87. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_typeinfo.py +36 -7
  88. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_urlhistory.py +7 -4
  89. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_variant.py +5 -3
  90. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_w_getopt.py +4 -4
  91. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_word.py +1 -1
  92. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/codegenerator.py +167 -435
  93. comtypes-1.4.11/comtypes/tools/codegenerator/comments.py +79 -0
  94. comtypes-1.4.11/comtypes/tools/codegenerator/heads.py +192 -0
  95. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/helpers.py +3 -6
  96. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/namespaces.py +13 -5
  97. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/typeannotator.py +13 -3
  98. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/tlbparser.py +25 -25
  99. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/typedesc.py +3 -2
  100. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/typedesc_base.py +2 -2
  101. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/typeinfo.py +163 -51
  102. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/viewobject.py +2 -4
  103. {comtypes-1.4.9 → comtypes-1.4.11/comtypes.egg-info}/PKG-INFO +4 -2
  104. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes.egg-info/SOURCES.txt +7 -0
  105. {comtypes-1.4.9 → comtypes-1.4.11}/pyproject.toml +10 -23
  106. comtypes-1.4.9/comtypes/client/__init__.py +0 -323
  107. comtypes-1.4.9/comtypes/server/register.py +0 -419
  108. comtypes-1.4.9/comtypes/test/find_memleak.py +0 -76
  109. {comtypes-1.4.9 → comtypes-1.4.11}/LICENSE.txt +0 -0
  110. {comtypes-1.4.9 → comtypes-1.4.11}/MANIFEST.in +0 -0
  111. {comtypes-1.4.9 → comtypes-1.4.11}/README.md +0 -0
  112. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_npsupport.py +0 -0
  113. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_post_coinit/__init__.py +0 -0
  114. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_tlib_version_checker.py +0 -0
  115. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/clear_cache.py +0 -0
  116. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/client/_constants.py +0 -0
  117. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/patcher.py +0 -0
  118. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/server/w_getopt.py +0 -0
  119. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/TestComServer.idl +0 -0
  120. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/TestComServer.tlb +0 -0
  121. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/TestDispServer.idl +0 -0
  122. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/TestDispServer.tlb +0 -0
  123. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/mylib.idl +0 -0
  124. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/mylib.tlb +0 -0
  125. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/mytypelib.idl +0 -0
  126. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_DISPPARAMS.py +0 -0
  127. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_avmc.py +0 -0
  128. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_casesensitivity.py +0 -0
  129. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_createwrappers.py +0 -0
  130. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_dispinterface.py +0 -0
  131. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_excel.py +0 -0
  132. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_jscript.js +0 -0
  133. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_pump_events.py +0 -0
  134. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_server.py +0 -0
  135. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_showevents.py +0 -0
  136. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_win32com_interop.py +0 -0
  137. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_wmi.py +0 -0
  138. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/urlhist.tlb +0 -0
  139. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/__init__.py +0 -0
  140. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/__init__.py +0 -0
  141. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/modulenamer.py +0 -0
  142. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/packing.py +0 -0
  143. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/util.py +0 -0
  144. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes.egg-info/dependency_links.txt +0 -0
  145. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes.egg-info/entry_points.txt +0 -0
  146. {comtypes-1.4.9 → comtypes-1.4.11}/comtypes.egg-info/top_level.txt +0 -0
  147. {comtypes-1.4.9 → comtypes-1.4.11}/setup.cfg +0 -0
  148. {comtypes-1.4.9 → comtypes-1.4.11}/setup.py +0 -0
@@ -1,6 +1,47 @@
1
1
  Comtypes CHANGELOG
2
2
  ==================
3
3
 
4
+ Release 1.4.11
5
+ --------------
6
+ * Improve ``PARAMFLAG_...`` and ``DISPATCH_...`` constants definitions and imports. By @junkmd.
7
+ * Introduce the ``_CDataType`` alias from typeshed. By @junkmd.
8
+ * Replace ``260`` literals/constant definitions with imports from ``ctypes.wintypes.MAX_PATH``. By @junkmd.
9
+ * Replace ``client._code_cache._get_module_filename`` with ``typeinfo.GetModuleFileName``. By @junkmd.
10
+ * Improve ``client._code_cache.SHGetSpecialFolderPath`` definition. By @junkmd.
11
+ * Add type annotations to many modules. By @junkmd.
12
+ * Add constants to many modules. By @junkmd.
13
+ * Improve import block styles to many modules. By @junkmd.
14
+ * Add ``SupportErrorInfoTest`` to ``test_comserver``. By @junkmd.
15
+ * Add ``test_errorinfo``. By @junkmd.
16
+ * Improve the type safety of ``errorinfo.ReportException``. By @junkmd.
17
+ * Change the method of retrieving the values of each field in ``_...MemberSpec`` from unpacking to dot access. By @junkmd.
18
+ * Split ``server.connectionpoints.ConnectionPointImpl._call_sinks``. By @junkmd.
19
+ * Refactor ``create_vtbl_mapping``, ``create_dispimpl`` and ``_encode_idl``. By @junkmd.
20
+ * Add ``test_hresult``. By @junkmd.
21
+ * Add ``Test_Vtbl`` to ``test_comobject.py``. By @junkmd.
22
+ * Delint ``IUnknown_AddRef`` and ``IUnknown_Release``. By @junkmd.
23
+ * Convert ``assertRaises`` usage to context manager for improved readability. By @junkmd.
24
+ * Remove the unused ``PATH`` variable from ``client/_generate.py``. By @moi15moi.
25
+
26
+ Release 1.4.10
27
+ --------------
28
+ * Replace ``GetModuleFileNameA`` with ``GetModuleFileNameW`` to prevent a ``TypeError``. By @junkmd.
29
+ * Refactor ``server.register``. By @junkmd.
30
+ * ``PythonClass`` and ``PythonPath`` are no longer registered in the registry for a frozen server. By @junkmd.
31
+ * Use ``WinDLL``/``OleDLL`` instead of ``windll``/``oledll``. By @moi15moi.
32
+ * In ``tools.tlbparser``, replace ``windll.oleaut32.QueryPathOfRegTypeLib`` with ``typeinfo.QueryPathOfRegTypeLib``. By @moi15moi.
33
+ * Adjust ``QueryPathOfRegTypeLib`` docstring. By @moi15moi.
34
+ * Reserve blank lines in the generated modules. By @junkmd.
35
+ * Refactor ``tools`` subpackage. By @junkmd.
36
+ * Add ``ActiveObjTest`` to ``test_comserver``. By @junkmd.
37
+ * Replace deprecated install command in CI pipelines. By @moi15moi.
38
+ * Remove unused parameters in ``_shutdown``. By @moi15moi.
39
+ * Delete ``preview.bat``. By @moi15moi.
40
+ * Remove unnecessary ``ruff`` lint rules from ``pyproject.toml``. By @moi15moi.
41
+ * Refactor some code from ``client/__init__.py`` into modules. By @junkmd.
42
+ * Remove workarounds for Windows CE in ``find_memleak``. By @junkmd.
43
+ * Format import blocks and add ``extend-select = ["I"]`` to ``[tool.ruff.lint]``. By @junkmd.
44
+
4
45
  Release 1.4.9
5
46
  --------------
6
47
  * Separate patch processing within ``_com_interface_meta`` into a module. By @junkmd.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: comtypes
3
- Version: 1.4.9
3
+ Version: 1.4.11
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
@@ -16,6 +16,8 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
16
  Requires-Python: >=3.8
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE.txt
19
+ Dynamic: download-url
20
+ Dynamic: license-file
19
21
 
20
22
  # comtypes
21
23
 
@@ -1,9 +1,8 @@
1
1
  """comtypes.GUID module"""
2
2
 
3
- from ctypes import oledll, windll
4
- from ctypes import byref, c_wchar_p, Structure
5
- from ctypes.wintypes import BYTE, WORD, DWORD
6
- from typing import Any, TYPE_CHECKING
3
+ from ctypes import HRESULT, POINTER, OleDLL, Structure, WinDLL, byref, c_wchar_p
4
+ from ctypes.wintypes import BYTE, DWORD, LPVOID, WORD
5
+ from typing import TYPE_CHECKING, Any
7
6
 
8
7
  if TYPE_CHECKING:
9
8
  from comtypes import hints # type: ignore
@@ -13,15 +12,6 @@ def binary(obj: "GUID") -> bytes:
13
12
  return bytes(obj)
14
13
 
15
14
 
16
- _ole32 = oledll.ole32
17
-
18
- _StringFromCLSID = _ole32.StringFromCLSID
19
- _CoTaskMemFree = windll.ole32.CoTaskMemFree
20
- _ProgIDFromCLSID = _ole32.ProgIDFromCLSID
21
- _CLSIDFromString = _ole32.CLSIDFromString
22
- _CLSIDFromProgID = _ole32.CLSIDFromProgID
23
- _CoCreateGuid = _ole32.CoCreateGuid
24
-
25
15
  # Note: Comparing GUID instances by comparing their buffers
26
16
  # is slightly faster than using ole32.IsEqualGUID.
27
17
 
@@ -93,6 +83,37 @@ class GUID(Structure):
93
83
  return guid
94
84
 
95
85
 
86
+ REFCLSID = POINTER(GUID)
87
+ LPOLESTR = LPCOLESTR = c_wchar_p
88
+ LPCLSID = POINTER(GUID)
89
+
90
+ _ole32_nohresult = WinDLL("ole32")
91
+ _ole32 = OleDLL("ole32")
92
+
93
+ _StringFromCLSID = _ole32.StringFromCLSID
94
+ _StringFromCLSID.argtypes = [REFCLSID, POINTER(LPOLESTR)]
95
+ _StringFromCLSID.restype = HRESULT
96
+
97
+ _CoTaskMemFree = _ole32_nohresult.CoTaskMemFree
98
+ _CoTaskMemFree.argtypes = [LPVOID]
99
+ _CoTaskMemFree.restype = None
100
+
101
+ _ProgIDFromCLSID = _ole32.ProgIDFromCLSID
102
+ _ProgIDFromCLSID.argtypes = [REFCLSID, POINTER(LPOLESTR)]
103
+ _ProgIDFromCLSID.restype = HRESULT
104
+
105
+ _CLSIDFromString = _ole32.CLSIDFromString
106
+ _CLSIDFromString.argtypes = [LPCOLESTR, LPCLSID]
107
+ _CLSIDFromString.restype = HRESULT
108
+
109
+ _CLSIDFromProgID = _ole32.CLSIDFromProgID
110
+ _CLSIDFromProgID.argtypes = [LPCOLESTR, LPCLSID]
111
+ _CLSIDFromProgID.restype = HRESULT
112
+
113
+ _CoCreateGuid = _ole32.CoCreateGuid
114
+ _CoCreateGuid.argtypes = [POINTER(GUID)]
115
+ _CoCreateGuid.restype = HRESULT
116
+
96
117
  GUID_null = GUID()
97
118
 
98
119
  __all__ = ["GUID"]
@@ -1,5 +1,5 @@
1
1
  # comtypes version numbers follow semver (http://semver.org/) and PEP 440
2
- __version__ = "1.4.9"
2
+ __version__ = "1.4.11"
3
3
 
4
4
  try:
5
5
  from _ctypes import COMError # noqa
@@ -15,31 +15,30 @@ except ImportError as e:
15
15
  raise ImportError(msg) from e
16
16
 
17
17
  import atexit
18
+ import logging
19
+ import sys
18
20
 
19
21
  # HACK: Workaround for projects that depend on this package
20
22
  # There should be several projects around the world that depend on this package
21
23
  # and indirectly reference the symbols of `ctypes` from `comtypes`.
22
24
  # If we remove the wildcard import from `ctypes`, they might break. So it is
23
25
  # left in the following line.
24
- from ctypes import * # noqa
25
- from ctypes import HRESULT # noqa
26
- from ctypes import _Pointer, _SimpleCData # noqa
27
- from ctypes import c_int, c_ulong, oledll, windll
28
- from ctypes.wintypes import DWORD # noqa
29
- import logging
30
- import sys
31
- from typing import TYPE_CHECKING
26
+ from ctypes import * # noqa # type: ignore
27
+ from ctypes import HRESULT, OleDLL, WinDLL, _SimpleCData, c_int, c_ulong
28
+ from ctypes.wintypes import DWORD, LPVOID
29
+ from typing import TYPE_CHECKING, Dict, Type
32
30
 
33
31
  if TYPE_CHECKING:
34
32
  from ctypes import _CData # only in `typeshed`, private in runtime
33
+
35
34
  from comtypes import hints as hints # noqa # type: ignore
36
35
  else:
37
36
  _CData = _SimpleCData.__mro__[:-1][-1]
38
37
 
39
- from comtypes.GUID import GUID
40
38
  from comtypes import patcher # noqa
41
39
  from comtypes._npsupport import interop as npsupport # noqa
42
40
  from comtypes._tlib_version_checker import _check_version # noqa
41
+ from comtypes.GUID import GUID
43
42
 
44
43
  _all_slice = slice(None, None, None)
45
44
 
@@ -121,8 +120,18 @@ EOAC_NONE = 0
121
120
 
122
121
  ################################################################
123
122
  # Initialization and shutdown
124
- _ole32 = oledll.ole32
125
- _ole32_nohresult = windll.ole32 # use this for functions that don't return a HRESULT
123
+ _ole32 = OleDLL("ole32")
124
+
125
+ _CoInitializeEx = _ole32.CoInitializeEx
126
+ _CoInitializeEx.argtypes = [LPVOID, DWORD]
127
+ _CoInitializeEx.restype = HRESULT
128
+
129
+ _ole32_nohresult = WinDLL("ole32") # use this for functions that don't return a HRESULT
130
+
131
+ _CoUninitialize = _ole32_nohresult.CoUninitialize
132
+ _CoUninitialize.argtypes = []
133
+ _CoUninitialize.restype = None
134
+
126
135
 
127
136
  COINIT_MULTITHREADED = 0x0
128
137
  COINIT_APARTMENTTHREADED = 0x2
@@ -138,7 +147,7 @@ def CoInitializeEx(flags=None):
138
147
  if flags is None:
139
148
  flags = getattr(sys, "coinit_flags", COINIT_APARTMENTTHREADED)
140
149
  logger.debug("CoInitializeEx(None, %s)", flags)
141
- _ole32.CoInitializeEx(None, flags)
150
+ _CoInitializeEx(None, flags)
142
151
 
143
152
 
144
153
  # COM is initialized automatically for the thread that imports this
@@ -156,17 +165,17 @@ CoInitializeEx()
156
165
  # in which we are using COM
157
166
  def CoUninitialize():
158
167
  logger.debug("CoUninitialize()")
159
- _ole32_nohresult.CoUninitialize()
168
+ _CoUninitialize()
160
169
 
161
170
 
162
171
  ################################################################
163
172
  # global registries.
164
173
 
165
174
  # allows to find interface classes by guid strings (iid)
166
- com_interface_registry = {}
175
+ com_interface_registry: Dict[str, Type["IUnknown"]] = {}
167
176
 
168
177
  # allows to find coclasses by guid strings (clsid)
169
- com_coclass_registry = {}
178
+ com_coclass_registry: Dict[str, Type["CoClass"]] = {}
170
179
 
171
180
 
172
181
  ################################################################
@@ -4,14 +4,15 @@ from _ctypes import COMError, CopyComPointer
4
4
  from ctypes import (
5
5
  POINTER,
6
6
  FormatError,
7
- Structure,
7
+ OleDLL,
8
+ WinDLL,
8
9
  byref,
9
10
  c_long,
10
11
  c_void_p,
11
- oledll,
12
+ c_wchar_p,
12
13
  pointer,
13
- windll,
14
14
  )
15
+ from ctypes.wintypes import INT, LONG, LPVOID, UINT, ULONG, WORD
15
16
  from typing import (
16
17
  TYPE_CHECKING,
17
18
  Any,
@@ -27,10 +28,21 @@ from typing import (
27
28
  )
28
29
  from typing import Union as _UnionT
29
30
 
30
- from comtypes import GUID, IPersist, IUnknown, hresult
31
+ import comtypes
32
+ from comtypes import GUID, IPersist, IUnknown, _CoUninitialize, hresult
33
+ from comtypes._memberspec import DISPATCH_METHOD as DISPATCH_METHOD
34
+ from comtypes._memberspec import DISPATCH_PROPERTYGET as DISPATCH_PROPERTYGET
35
+ from comtypes._memberspec import DISPATCH_PROPERTYPUT as DISPATCH_PROPERTYPUT
36
+ from comtypes._memberspec import DISPATCH_PROPERTYPUTREF as DISPATCH_PROPERTYPUTREF
31
37
  from comtypes._vtbl import _MethodFinder, create_dispimpl, create_vtbl_mapping
38
+ from comtypes.automation import DISPID, DISPPARAMS, EXCEPINFO, VARIANT
32
39
  from comtypes.errorinfo import ISupportErrorInfo
33
- from comtypes.typeinfo import IProvideClassInfo, IProvideClassInfo2, ITypeInfo
40
+ from comtypes.typeinfo import (
41
+ GUIDKIND_DEFAULT_SOURCE_DISP_IID,
42
+ IProvideClassInfo,
43
+ IProvideClassInfo2,
44
+ ITypeInfo,
45
+ )
34
46
 
35
47
  if TYPE_CHECKING:
36
48
  from ctypes import _CArgObject, _Pointer
@@ -43,17 +55,13 @@ _debug = logger.debug
43
55
  ################################################################
44
56
  # COM object implementation
45
57
 
46
- # so we don't have to import comtypes.automation
47
- DISPATCH_METHOD = 1
48
- DISPATCH_PROPERTYGET = 2
49
- DISPATCH_PROPERTYPUT = 4
50
- DISPATCH_PROPERTYPUTREF = 8
51
58
 
52
59
  ################################################################
53
60
 
61
+ _kernel32 = WinDLL("kernel32")
54
62
  try:
55
- _InterlockedIncrement = windll.kernel32.InterlockedIncrement
56
- _InterlockedDecrement = windll.kernel32.InterlockedDecrement
63
+ _InterlockedIncrement = _kernel32.InterlockedIncrement
64
+ _InterlockedDecrement = _kernel32.InterlockedDecrement
57
65
  except AttributeError:
58
66
  import threading
59
67
 
@@ -82,14 +90,65 @@ else:
82
90
  _InterlockedIncrement.restype = c_long
83
91
  _InterlockedDecrement.restype = c_long
84
92
 
93
+ _oleaut32 = WinDLL("oleaut32")
94
+
95
+ _DispGetIDsOfNames = _oleaut32.DispGetIDsOfNames
96
+ _DispGetIDsOfNames.argtypes = [
97
+ POINTER(ITypeInfo),
98
+ POINTER(c_wchar_p),
99
+ UINT,
100
+ POINTER(DISPID),
101
+ ]
102
+ _DispGetIDsOfNames.restype = (
103
+ LONG # technically, it is a HRESULT, but we want to avoid the OSError
104
+ )
105
+
106
+ _DispInvoke = _oleaut32.DispInvoke
107
+ _DispInvoke.argtypes = [
108
+ LPVOID,
109
+ POINTER(ITypeInfo),
110
+ DISPID,
111
+ WORD,
112
+ POINTER(DISPPARAMS),
113
+ POINTER(VARIANT),
114
+ POINTER(EXCEPINFO),
115
+ POINTER(UINT),
116
+ ]
117
+ _DispInvoke.restype = (
118
+ LONG # technically, it is a HRESULT, but we want to avoid the OSError
119
+ )
120
+
121
+
122
+ _ole32_nohresult = WinDLL("ole32")
123
+ _ole32 = OleDLL("ole32")
124
+
125
+ _CoInitialize = _ole32_nohresult.CoInitialize
126
+ _CoInitialize.argtypes = [LPVOID]
127
+ _CoInitialize.restype = (
128
+ LONG # technically, it is a HRESULT, but we want to avoid the OSError
129
+ )
130
+
131
+ _CoAddRefServerProcess = _ole32.CoAddRefServerProcess
132
+ _CoAddRefServerProcess.argtypes = []
133
+ _CoAddRefServerProcess.restype = ULONG
134
+
135
+ _CoReleaseServerProcess = _ole32.CoReleaseServerProcess
136
+ _CoReleaseServerProcess.argtypes = []
137
+ _CoReleaseServerProcess.restype = ULONG
138
+
139
+
140
+ _user32 = WinDLL("user32")
141
+
142
+ _PostQuitMessage = _user32.PostQuitMessage
143
+ _PostQuitMessage.argtypes = [INT]
144
+ _PostQuitMessage.restype = None
145
+
85
146
 
86
147
  class LocalServer(object):
87
148
  _queue: Optional[queue.Queue] = None
88
149
 
89
150
  def run(self, classobjects: Sequence["hints.localserver.ClassFactory"]) -> None:
90
- # Use windll instead of oledll so that we don't get an
91
- # exception on a FAILED hresult:
92
- hr = windll.ole32.CoInitialize(None)
151
+ hr = _CoInitialize(None)
93
152
  if hresult.RPC_E_CHANGED_MODE == hr:
94
153
  # we're running in MTA: no message pump needed
95
154
  _debug("Server running in MTA")
@@ -100,7 +159,7 @@ class LocalServer(object):
100
159
  if hr >= 0:
101
160
  # we need a matching CoUninitialize() call for a successful
102
161
  # CoInitialize().
103
- windll.ole32.CoUninitialize()
162
+ _CoUninitialize()
104
163
  self.run_sta()
105
164
 
106
165
  for obj in classobjects:
@@ -116,15 +175,15 @@ class LocalServer(object):
116
175
  self._queue.get()
117
176
 
118
177
  def Lock(self) -> None:
119
- oledll.ole32.CoAddRefServerProcess()
178
+ _CoAddRefServerProcess()
120
179
 
121
180
  def Unlock(self) -> None:
122
- rc = oledll.ole32.CoReleaseServerProcess()
181
+ rc = _CoReleaseServerProcess()
123
182
  if rc == 0:
124
183
  if self._queue:
125
184
  self._queue.put(42)
126
185
  else:
127
- windll.user32.PostQuitMessage(0)
186
+ _PostQuitMessage(0)
128
187
 
129
188
 
130
189
  class InprocServer(object):
@@ -155,18 +214,18 @@ class COMObject(object):
155
214
  _reg_clsid_: ClassVar[GUID]
156
215
  _reg_typelib_: ClassVar[Tuple[str, int, int]]
157
216
  __typelib: "hints.ITypeLib"
158
- _com_pointers_: Dict[GUID, "_Pointer[_Pointer[Structure]]"]
159
- _dispimpl_: Dict[Tuple[int, int], Callable[..., Any]]
217
+ _com_pointers_: Dict[GUID, "hints.LP_LP_Vtbl"]
218
+ _dispimpl_: Dict[Tuple[comtypes.dispid, int], Callable[..., Any]]
160
219
 
161
- def __new__(cls, *args, **kw):
220
+ def __new__(cls, *args: Any, **kw: Any) -> "hints.Self":
162
221
  self = super(COMObject, cls).__new__(cls)
163
222
  if isinstance(self, c_void_p):
164
223
  # We build the VTables only for direct instances of
165
224
  # CoClass, not for POINTERs to CoClass.
166
- return self
225
+ return self # type: ignore
167
226
  if hasattr(self, "_com_interfaces_"):
168
227
  self.__prepare_comobject()
169
- return self
228
+ return self # type: ignore
170
229
 
171
230
  def __prepare_comobject(self) -> None:
172
231
  # When a CoClass instance is created, COM pointers to all
@@ -271,10 +330,10 @@ class COMObject(object):
271
330
  def IUnknown_AddRef(
272
331
  self,
273
332
  this: Any,
274
- __InterlockedIncrement: Callable[[c_long], int] = _InterlockedIncrement,
333
+ _increment: Callable[[c_long], int] = _InterlockedIncrement,
275
334
  _debug=_debug,
276
335
  ) -> int:
277
- result = __InterlockedIncrement(self._refcnt)
336
+ result = _increment(self._refcnt)
278
337
  if result == 1:
279
338
  self.__keep__(self)
280
339
  _debug("%r.AddRef() -> %s", self, result)
@@ -288,14 +347,14 @@ class COMObject(object):
288
347
  def IUnknown_Release(
289
348
  self,
290
349
  this: Any,
291
- __InterlockedDecrement: Callable[[c_long], int] = _InterlockedDecrement,
350
+ _decrement: Callable[[c_long], int] = _InterlockedDecrement,
292
351
  _debug=_debug,
293
352
  ) -> int:
294
353
  # If this is called at COM shutdown, _InterlockedDecrement()
295
354
  # must still be available, although module level variables may
296
355
  # have been deleted already - so we supply it as default
297
356
  # argument.
298
- result = __InterlockedDecrement(self._refcnt)
357
+ result = _decrement(self._refcnt)
299
358
  _debug("%r.Release() -> %s", self, result)
300
359
  if result == 0:
301
360
  self._final_release_()
@@ -362,8 +421,7 @@ class COMObject(object):
362
421
  # IProvideClassInfo2::GetGUID implementation
363
422
 
364
423
  def IProvideClassInfo2_GetGUID(self, dwGuidKind: int) -> GUID:
365
- # GUIDKIND_DEFAULT_SOURCE_DISP_IID = 1
366
- if dwGuidKind != 1:
424
+ if dwGuidKind != GUIDKIND_DEFAULT_SOURCE_DISP_IID:
367
425
  raise WindowsError(hresult.E_INVALIDARG)
368
426
  return self._outgoing_interfaces_[0]._iid_
369
427
 
@@ -401,7 +459,7 @@ class COMObject(object):
401
459
  tinfo = self.__typeinfo
402
460
  except AttributeError:
403
461
  return hresult.E_NOTIMPL
404
- return windll.oleaut32.DispGetIDsOfNames(tinfo, rgszNames, cNames, rgDispId)
462
+ return _DispGetIDsOfNames(tinfo, rgszNames, cNames, rgDispId)
405
463
 
406
464
  def IDispatch_Invoke(
407
465
  self,
@@ -432,7 +490,7 @@ class COMObject(object):
432
490
  # an error.
433
491
  interface = self._com_interfaces_[0]
434
492
  ptr = self._com_pointers_[interface._iid_]
435
- return windll.oleaut32.DispInvoke(
493
+ return _DispInvoke(
436
494
  ptr,
437
495
  tinfo,
438
496
  dispIdMember,
@@ -461,10 +519,7 @@ class COMObject(object):
461
519
  #
462
520
  params = pDispParams[0]
463
521
 
464
- if wFlags & (4 | 8):
465
- # DISPATCH_PROPERTYPUT
466
- # DISPATCH_PROPERTYPUTREF
467
- #
522
+ if wFlags & (DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYPUTREF):
468
523
  # How are the parameters unpacked for propertyput
469
524
  # operations with additional parameters? Can propput
470
525
  # have additional args?
@@ -475,9 +530,7 @@ class COMObject(object):
475
530
  # DISPATCH_PROPERTYPUTREF is specified.
476
531
  return mth(this, *args)
477
532
 
478
- else:
479
- # DISPATCH_METHOD
480
- # DISPATCH_PROPERTYGET
533
+ else: # wFlags & (DISPATCH_METHOD | DISPATCH_PROPERTYGET)
481
534
  # the positions of named arguments
482
535
  #
483
536
  # 2to3 has problems to translate 'range(...)[::-1]'