comtypes 1.4.10__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 (145) hide show
  1. {comtypes-1.4.10 → comtypes-1.4.11}/CHANGES.txt +22 -0
  2. {comtypes-1.4.10/comtypes.egg-info → comtypes-1.4.11}/PKG-INFO +3 -2
  3. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/__init__.py +4 -4
  4. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_comobject.py +23 -25
  5. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_memberspec.py +100 -74
  6. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_meta.py +1 -1
  7. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_post_coinit/_cominterface_meta_patcher.py +3 -5
  8. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_post_coinit/unknwn.py +29 -20
  9. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_vtbl.py +52 -55
  10. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/automation.py +9 -10
  11. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_code_cache.py +9 -23
  12. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_events.py +87 -49
  13. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_generate.py +0 -2
  14. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/connectionpoints.py +37 -3
  15. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/errorinfo.py +53 -15
  16. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/hints.pyi +15 -2
  17. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/hresult.py +16 -6
  18. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/messageloop.py +14 -12
  19. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/connectionpoints.py +68 -67
  20. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/inprocserver.py +8 -5
  21. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/localserver.py +14 -20
  22. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/register.py +2 -2
  23. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_GUID.py +6 -7
  24. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_basic.py +6 -3
  25. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_collections.py +6 -3
  26. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_comobject.py +19 -6
  27. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_comserver.py +25 -2
  28. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_dict.py +2 -1
  29. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_dyndispatch.py +4 -2
  30. comtypes-1.4.11/comtypes/test/test_errorinfo.py +115 -0
  31. comtypes-1.4.11/comtypes/test/test_hresult.py +48 -0
  32. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_inout_args.py +9 -2
  33. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_safearray.py +2 -1
  34. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_server_register.py +2 -1
  35. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_typeinfo.py +19 -2
  36. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_variant.py +2 -1
  37. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_w_getopt.py +4 -4
  38. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/tlbparser.py +7 -6
  39. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/typeinfo.py +14 -9
  40. {comtypes-1.4.10 → comtypes-1.4.11/comtypes.egg-info}/PKG-INFO +3 -2
  41. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes.egg-info/SOURCES.txt +2 -0
  42. {comtypes-1.4.10 → comtypes-1.4.11}/pyproject.toml +1 -6
  43. {comtypes-1.4.10 → comtypes-1.4.11}/LICENSE.txt +0 -0
  44. {comtypes-1.4.10 → comtypes-1.4.11}/MANIFEST.in +0 -0
  45. {comtypes-1.4.10 → comtypes-1.4.11}/README.md +0 -0
  46. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/GUID.py +0 -0
  47. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_npsupport.py +0 -0
  48. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_post_coinit/__init__.py +0 -0
  49. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_post_coinit/bstr.py +0 -0
  50. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_post_coinit/instancemethod.py +0 -0
  51. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_post_coinit/misc.py +0 -0
  52. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_safearray.py +0 -0
  53. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_tlib_version_checker.py +0 -0
  54. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/clear_cache.py +0 -0
  55. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/__init__.py +0 -0
  56. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_activeobj.py +0 -0
  57. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_constants.py +0 -0
  58. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_create.py +0 -0
  59. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_managing.py +0 -0
  60. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/dynamic.py +0 -0
  61. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/lazybind.py +0 -0
  62. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/git.py +0 -0
  63. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/logutil.py +0 -0
  64. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/patcher.py +0 -0
  65. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/persist.py +0 -0
  66. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/safearray.py +0 -0
  67. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/__init__.py +0 -0
  68. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/automation.py +0 -0
  69. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/w_getopt.py +0 -0
  70. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/shelllink.py +0 -0
  71. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/stream.py +0 -0
  72. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/TestComServer.idl +0 -0
  73. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/TestComServer.py +0 -0
  74. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/TestComServer.tlb +0 -0
  75. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/TestDispServer.idl +0 -0
  76. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/TestDispServer.py +0 -0
  77. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/TestDispServer.tlb +0 -0
  78. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/__init__.py +0 -0
  79. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/find_memleak.py +0 -0
  80. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/mylib.idl +0 -0
  81. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/mylib.tlb +0 -0
  82. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/mytypelib.idl +0 -0
  83. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/runtests.py +0 -0
  84. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/setup.py +0 -0
  85. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_BSTR.py +0 -0
  86. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_DISPPARAMS.py +0 -0
  87. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_QueryService.py +0 -0
  88. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_agilent.py +0 -0
  89. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_avmc.py +0 -0
  90. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_casesensitivity.py +0 -0
  91. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_clear_cache.py +0 -0
  92. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_client.py +0 -0
  93. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_client_dynamic.py +0 -0
  94. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_client_regenerate_modules.py +0 -0
  95. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_createwrappers.py +0 -0
  96. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_dispifc_records.py +0 -0
  97. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_dispifc_safearrays.py +0 -0
  98. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_dispinterface.py +0 -0
  99. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_excel.py +0 -0
  100. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_findgendir.py +0 -0
  101. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_getactiveobj.py +0 -0
  102. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_ie.py +0 -0
  103. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_ienum.py +0 -0
  104. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_imfattributes.py +0 -0
  105. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_jscript.js +0 -0
  106. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_midl_safearray_create.py +0 -0
  107. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_monikers.py +0 -0
  108. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_msscript.py +0 -0
  109. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_npsupport.py +0 -0
  110. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_outparam.py +0 -0
  111. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_persist.py +0 -0
  112. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_pump_events.py +0 -0
  113. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_recordinfo.py +0 -0
  114. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_sapi.py +0 -0
  115. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_server.py +0 -0
  116. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_shelllink.py +0 -0
  117. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_showevents.py +0 -0
  118. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_storage.py +0 -0
  119. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_stream.py +0 -0
  120. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_subinterface.py +0 -0
  121. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_typeannotator.py +0 -0
  122. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_urlhistory.py +0 -0
  123. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_win32com_interop.py +0 -0
  124. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_wmi.py +0 -0
  125. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_word.py +0 -0
  126. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/urlhist.tlb +0 -0
  127. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/__init__.py +0 -0
  128. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/__init__.py +0 -0
  129. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/codegenerator.py +0 -0
  130. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/comments.py +0 -0
  131. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/heads.py +0 -0
  132. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/helpers.py +0 -0
  133. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/modulenamer.py +0 -0
  134. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/namespaces.py +0 -0
  135. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/packing.py +0 -0
  136. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/typeannotator.py +0 -0
  137. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/typedesc.py +0 -0
  138. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/typedesc_base.py +0 -0
  139. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/util.py +0 -0
  140. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/viewobject.py +0 -0
  141. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes.egg-info/dependency_links.txt +0 -0
  142. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes.egg-info/entry_points.txt +0 -0
  143. {comtypes-1.4.10 → comtypes-1.4.11}/comtypes.egg-info/top_level.txt +0 -0
  144. {comtypes-1.4.10 → comtypes-1.4.11}/setup.cfg +0 -0
  145. {comtypes-1.4.10 → comtypes-1.4.11}/setup.py +0 -0
@@ -0,0 +1,115 @@
1
+ import unittest as ut
2
+
3
+ from comtypes import errorinfo, shelllink
4
+ from comtypes import hresult as hres
5
+
6
+
7
+ class Test_GetErrorInfo(ut.TestCase):
8
+ def test_error_has_been_set(self):
9
+ self.assertIsNone(errorinfo.GetErrorInfo())
10
+ errmsg = "sample unexpected error message for tests"
11
+ errcode = hres.E_UNEXPECTED
12
+ helpcontext = 123
13
+ hr = errorinfo.ReportError(
14
+ errmsg,
15
+ shelllink.IShellLinkW._iid_,
16
+ str(shelllink.ShellLink._reg_clsid_),
17
+ helpfile="help.chm",
18
+ helpcontext=helpcontext,
19
+ hresult=errcode,
20
+ )
21
+ self.assertEqual(errcode, hr)
22
+ pei = errorinfo.GetErrorInfo()
23
+ self.assertIsNotNone(pei)
24
+ assert pei is not None # for static type guard
25
+ self.assertEqual(shelllink.IShellLinkW._iid_, pei.GetGUID())
26
+ self.assertEqual("lnkfile", pei.GetSource())
27
+ self.assertEqual(errmsg, pei.GetDescription())
28
+ self.assertEqual("help.chm", pei.GetHelpFile())
29
+ self.assertEqual(helpcontext, pei.GetHelpContext())
30
+ # Calling `GetErrorInfo` clears the error state for the thread.
31
+ # Therefore, `None` is returned in the second call.
32
+ self.assertIsNone(errorinfo.GetErrorInfo())
33
+
34
+ def test_without_optional_args(self):
35
+ self.assertIsNone(errorinfo.GetErrorInfo())
36
+ errmsg = "sample unexpected error message for tests"
37
+ hr = errorinfo.ReportError(errmsg, shelllink.IShellLinkW._iid_)
38
+ self.assertEqual(hres.DISP_E_EXCEPTION, hr)
39
+ pei = errorinfo.GetErrorInfo()
40
+ self.assertIsNotNone(pei)
41
+ assert pei is not None # for static type guard
42
+ self.assertEqual(shelllink.IShellLinkW._iid_, pei.GetGUID())
43
+ self.assertIsNone(pei.GetSource())
44
+ self.assertEqual(errmsg, pei.GetDescription())
45
+ self.assertIsNone(pei.GetHelpFile())
46
+ self.assertEqual(0, pei.GetHelpContext())
47
+
48
+ def test_error_has_not_been_set(self):
49
+ self.assertIsNone(errorinfo.GetErrorInfo())
50
+ pei = errorinfo.GetErrorInfo()
51
+ self.assertIsNone(pei)
52
+
53
+
54
+ def raise_runtime_error():
55
+ _raise_runtime_error()
56
+
57
+
58
+ def _raise_runtime_error():
59
+ raise RuntimeError("for testing")
60
+
61
+
62
+ class Test_ReportException(ut.TestCase):
63
+ def test_without_stacklevel(self):
64
+ self.assertIsNone(errorinfo.GetErrorInfo())
65
+ iid = shelllink.IShellLinkW._iid_
66
+ try:
67
+ raise_runtime_error()
68
+ except RuntimeError:
69
+ hr = errorinfo.ReportException(hres.E_UNEXPECTED, iid)
70
+ self.assertEqual(hres.E_UNEXPECTED, hr)
71
+ pei = errorinfo.GetErrorInfo()
72
+ self.assertIsNotNone(pei)
73
+ assert pei is not None # for static type guard
74
+ self.assertEqual(shelllink.IShellLinkW._iid_, pei.GetGUID())
75
+ self.assertIsNone(pei.GetSource())
76
+ self.assertEqual("<class 'RuntimeError'>: for testing", pei.GetDescription())
77
+ self.assertIsNone(pei.GetHelpFile())
78
+ self.assertEqual(0, pei.GetHelpContext())
79
+ self.assertIsNone(errorinfo.GetErrorInfo())
80
+
81
+ def test_with_stacklevel(self):
82
+ self.assertIsNone(errorinfo.GetErrorInfo())
83
+ stem = "<class 'RuntimeError'>: for testing"
84
+ iid = shelllink.IShellLinkW._iid_
85
+ for slv, text in [
86
+ # XXX: If the codebase changes, the line where functions or
87
+ # methods are defined will change, meaning this test is brittle.
88
+ (0, f"{stem} ({__name__}, line 96)"),
89
+ (1, f"{stem} ({__name__}, line 55)"),
90
+ (2, f"{stem} ({__name__}, line 59)"),
91
+ ]:
92
+ with self.subTest(text=text):
93
+ try:
94
+ raise_runtime_error()
95
+ except RuntimeError:
96
+ errorinfo.ReportException(hres.E_UNEXPECTED, iid, stacklevel=slv)
97
+ pei = errorinfo.GetErrorInfo()
98
+ assert pei is not None # for static type guard
99
+ self.assertEqual(text, pei.GetDescription())
100
+ self.assertIsNone(errorinfo.GetErrorInfo())
101
+
102
+ def test_with_over_stacklevel(self):
103
+ self.assertIsNone(errorinfo.GetErrorInfo())
104
+ iid = shelllink.IShellLinkW._iid_
105
+ try:
106
+ raise_runtime_error()
107
+ except RuntimeError:
108
+ with self.assertRaises(ValueError):
109
+ errorinfo.ReportException(hres.E_UNEXPECTED, iid, stacklevel=4)
110
+
111
+ def test_with_no_error_and_zero_stacklevel(self):
112
+ self.assertIsNone(errorinfo.GetErrorInfo())
113
+ iid = shelllink.IShellLinkW._iid_
114
+ with self.assertRaises(ValueError):
115
+ errorinfo.ReportException(hres.E_UNEXPECTED, iid, stacklevel=0)
@@ -0,0 +1,48 @@
1
+ import unittest as ut
2
+
3
+ import comtypes.hresult
4
+
5
+
6
+ class Test_MAKE_HRESULT(ut.TestCase):
7
+ def test(self):
8
+ for sev, fac, code, hr in [
9
+ (0x0000, 0x0000, 0x0000, 0),
10
+ (0x0001, 0x0000, 0x0000, -2147483648),
11
+ (0x0000, 0x0001, 0x0000, 65536),
12
+ (0x0000, 0x0000, 0x0001, 1),
13
+ (0x0001, 0xFFFF, 0xFFFF, -1),
14
+ (0x0000, 0xFFFF, 0xFFFF, -1),
15
+ (0x0001, 0x0000, 0x0001, -2147483647),
16
+ (0x0001, 0x0001, 0x0001, -2147418111),
17
+ (0x0000, 0x0001, 0xFFFF, 131071),
18
+ (0x0001, 0xFFFF, 0x0000, -65536),
19
+ (0x0001, 0x0000, 0xFFFF, -2147418113),
20
+ ]:
21
+ with self.subTest(sev=sev, fac=fac, code=code, hr=hr):
22
+ self.assertEqual(comtypes.hresult.MAKE_HRESULT(sev, fac, code), hr)
23
+
24
+
25
+ ERROR_OUTOFMEMORY = 14 # 0xE
26
+ ERROR_INVALID_PARAMETER = 87 # 0x57
27
+ RPC_S_SERVER_UNAVAILABLE = 1722 # 0x6BA
28
+
29
+
30
+ class Test_HRESULT_FROM_WIN32(ut.TestCase):
31
+ def test(self):
32
+ for w32, hr in [
33
+ (ERROR_OUTOFMEMORY, comtypes.hresult.E_OUTOFMEMORY),
34
+ (ERROR_INVALID_PARAMETER, comtypes.hresult.E_INVALIDARG),
35
+ (RPC_S_SERVER_UNAVAILABLE, comtypes.hresult.RPC_S_SERVER_UNAVAILABLE),
36
+ (-1, -1),
37
+ (0, -2147024896),
38
+ (1, -2147024895),
39
+ (0xFFFF - 3, -2146959364),
40
+ (0xFFFF - 2, -2146959363),
41
+ (0xFFFF - 1, -2146959362),
42
+ (0xFFFF + 0, -2146959361),
43
+ (0xFFFF + 1, -2147024896),
44
+ (0xFFFF + 2, -2147024895),
45
+ (0xFFFF + 3, -2147024894),
46
+ ]:
47
+ with self.subTest(w32=w32, hr=hr):
48
+ self.assertEqual(comtypes.hresult.HRESULT_FROM_WIN32(w32), hr)
@@ -8,7 +8,14 @@ from comtypes import IUnknown
8
8
  from comtypes._memberspec import _fix_inout_args
9
9
 
10
10
  if TYPE_CHECKING:
11
- from comtypes._memberspec import _ArgSpecElmType
11
+ from comtypes import hints # type: ignore
12
+
13
+ _ArgSpecType = Tuple[
14
+ hints.ArgSpecElmType,
15
+ hints.ArgSpecElmType,
16
+ hints.ArgSpecElmType,
17
+ hints.ArgSpecElmType,
18
+ ]
12
19
 
13
20
  WSTRING = c_wchar_p
14
21
 
@@ -259,7 +266,7 @@ class Test_ArgsKwargsCombinations(ut.TestCase):
259
266
 
260
267
 
261
268
  class PermutedArgspecTestingParams(NamedTuple):
262
- argspec: "Tuple[_ArgSpecElmType, _ArgSpecElmType, _ArgSpecElmType, _ArgSpecElmType]"
269
+ argspec: "_ArgSpecType"
263
270
  args: Tuple[Any, Any, Any]
264
271
  orig_ret_val: Tuple[Any, Any, Any]
265
272
  fixed_ret_val: List[Any]
@@ -129,7 +129,8 @@ class SafeArrayTestCase(unittest.TestCase):
129
129
  self.assertEqual(SafeArrayGetVartype(sa), VT_I4)
130
130
 
131
131
  # TypeError: len() of unsized object
132
- self.assertRaises(TypeError, lambda: t.from_param(object()))
132
+ with self.assertRaises(TypeError):
133
+ t.from_param(object())
133
134
 
134
135
  def test_VT_VARIANT(self):
135
136
  t = _midlSAFEARRAY(VARIANT)
@@ -3,6 +3,7 @@ import os
3
3
  import sys
4
4
  import unittest as ut
5
5
  import winreg
6
+ from ctypes.wintypes import MAX_PATH
6
7
  from unittest import mock
7
8
 
8
9
  import comtypes
@@ -236,7 +237,7 @@ class Test_get_serverdll(ut.TestCase):
236
237
  self.assertEqual(dll_path, _get_serverdll(handle))
237
238
  (((hmodule, maxsize), _),) = GetModuleFileName.call_args_list
238
239
  self.assertEqual(handle, hmodule)
239
- self.assertEqual(260, maxsize)
240
+ self.assertEqual(MAX_PATH, maxsize)
240
241
 
241
242
 
242
243
  class Test_InterpRegistryEntries(ut.TestCase):
@@ -1,6 +1,7 @@
1
1
  import ctypes
2
2
  import sys
3
3
  import unittest
4
+ from ctypes.wintypes import MAX_PATH
4
5
 
5
6
  from comtypes import GUID, COMError
6
7
  from comtypes.typeinfo import (
@@ -96,14 +97,30 @@ class Test(unittest.TestCase):
96
97
 
97
98
  class Test_GetModuleFileName(unittest.TestCase):
98
99
  def test_null_handler(self):
99
- self.assertEqual(GetModuleFileName(None, 260), sys.executable)
100
+ self.assertEqual(GetModuleFileName(None, MAX_PATH), sys.executable)
100
101
 
101
102
  def test_loaded_module_handle(self):
102
103
  import _ctypes
103
104
 
104
105
  dll_path = _ctypes.__file__
105
106
  hmodule = ctypes.WinDLL(dll_path)._handle
106
- self.assertEqual(GetModuleFileName(hmodule, 260), dll_path)
107
+ self.assertEqual(GetModuleFileName(hmodule, MAX_PATH), dll_path)
108
+
109
+ def test_invalid_handle(self):
110
+ with self.assertRaises(OSError) as ce:
111
+ GetModuleFileName(1, MAX_PATH)
112
+ ERROR_MOD_NOT_FOUND = 126
113
+ self.assertEqual(ce.exception.winerror, ERROR_MOD_NOT_FOUND)
114
+
115
+ def test_invalid_nsize(self):
116
+ import _ctypes
117
+
118
+ dll_path = _ctypes.__file__
119
+ hmodule = ctypes.WinDLL(dll_path)._handle
120
+ with self.assertRaises(OSError) as ce:
121
+ GetModuleFileName(hmodule, 0)
122
+ ERROR_INSUFFICIENT_BUFFER = 122
123
+ self.assertEqual(ce.exception.winerror, ERROR_INSUFFICIENT_BUFFER)
107
124
 
108
125
 
109
126
  if __name__ == "__main__":
@@ -66,7 +66,8 @@ class VariantTestCase(unittest.TestCase):
66
66
 
67
67
  missing = VARIANT.missing
68
68
  self.assertEqual(missing.vt, VT_ERROR)
69
- self.assertRaises(NotImplementedError, lambda: missing.value)
69
+ with self.assertRaises(NotImplementedError):
70
+ missing.value
70
71
 
71
72
  def test_com_refcounts(self):
72
73
  # typelib for oleaut32
@@ -20,10 +20,10 @@ class TestCase(unittest.TestCase):
20
20
 
21
21
  def test_3(self):
22
22
  # Invalid option
23
- self.assertRaises(
24
- GetoptError, w_getopt, "/TLIB hello.tlb hello.idl".split(), ["tlb:"]
25
- )
23
+ with self.assertRaises(GetoptError):
24
+ w_getopt("/TLIB hello.tlb hello.idl".split(), ["tlb:"])
26
25
 
27
26
  def test_4(self):
28
27
  # Missing argument
29
- self.assertRaises(GetoptError, w_getopt, "/TLB".split(), ["tlb:"])
28
+ with self.assertRaises(GetoptError):
29
+ w_getopt("/TLB".split(), ["tlb:"])
@@ -1,10 +1,11 @@
1
1
  import os
2
2
  import sys
3
+ from _ctypes import COMError
3
4
  from ctypes import alignment, c_void_p, sizeof, windll
5
+ from ctypes.wintypes import MAX_PATH
4
6
  from typing import Any, Dict, List, Optional, Tuple
5
7
 
6
- from comtypes import BSTR, COMError, automation, typeinfo
7
- from comtypes.client._code_cache import _get_module_filename
8
+ from comtypes import automation, typeinfo
8
9
  from comtypes.tools import typedesc
9
10
 
10
11
  # Is the process 64-bit?
@@ -750,7 +751,7 @@ def get_tlib_filename(tlib: typeinfo.ITypeLib) -> Optional[str]:
750
751
  # workaround Windows 7 bug in QueryPathOfRegTypeLib returning relative path
751
752
  try:
752
753
  dll = windll.LoadLibrary(full_filename)
753
- full_filename = _get_module_filename(dll._handle)
754
+ full_filename = typeinfo.GetModuleFileName(dll._handle, MAX_PATH)
754
755
  del dll
755
756
  except OSError:
756
757
  return None
@@ -759,9 +760,9 @@ def get_tlib_filename(tlib: typeinfo.ITypeLib) -> Optional[str]:
759
760
 
760
761
  def _py2exe_hint():
761
762
  # If the tlbparser is frozen, we need to include these
762
- import comtypes.automation
763
- import comtypes.persist
764
- import comtypes.typeinfo
763
+ import comtypes.automation # noqa
764
+ import comtypes.persist # noqa
765
+ import comtypes.typeinfo # noqa
765
766
 
766
767
 
767
768
  # -eof-
@@ -45,6 +45,14 @@ from typing import (
45
45
  from typing import Union as _UnionT
46
46
 
47
47
  from comtypes import BSTR, COMMETHOD, GUID, IID, STDMETHOD, IUnknown, _CData
48
+ from comtypes._memberspec import PARAMFLAG_FHASCUSTDATA as PARAMFLAG_FHASCUSTDATA
49
+ from comtypes._memberspec import PARAMFLAG_FHASDEFAULT as PARAMFLAG_FHASDEFAULT
50
+ from comtypes._memberspec import PARAMFLAG_FIN as PARAMFLAG_FIN
51
+ from comtypes._memberspec import PARAMFLAG_FLCID as PARAMFLAG_FLCID
52
+ from comtypes._memberspec import PARAMFLAG_FOPT as PARAMFLAG_FOPT
53
+ from comtypes._memberspec import PARAMFLAG_FOUT as PARAMFLAG_FOUT
54
+ from comtypes._memberspec import PARAMFLAG_FRETVAL as PARAMFLAG_FRETVAL
55
+ from comtypes._memberspec import PARAMFLAG_NONE as PARAMFLAG_NONE
48
56
  from comtypes.automation import (
49
57
  DISPID,
50
58
  DISPPARAMS,
@@ -205,15 +213,6 @@ VARFLAG_FREPLACEABLE = 2048
205
213
  VARFLAG_FIMMEDIATEBIND = 4096
206
214
  VARFLAGS = tagVARFLAGS
207
215
 
208
- PARAMFLAG_NONE = 0
209
- PARAMFLAG_FIN = 1
210
- PARAMFLAG_FOUT = 2
211
- PARAMFLAG_FLCID = 4
212
- PARAMFLAG_FRETVAL = 8
213
- PARAMFLAG_FOPT = 16
214
- PARAMFLAG_FHASDEFAULT = 32
215
- PARAMFLAG_FHASCUSTDATA = 64
216
-
217
216
  ################################################################
218
217
  # a helper
219
218
 
@@ -770,6 +769,8 @@ def GetModuleFileName(handle: Optional[int], maxsize: int) -> str:
770
769
  """
771
770
  buf = create_unicode_buffer(maxsize)
772
771
  length = _GetModuleFileNameW(handle, buf, maxsize)
772
+ if not length:
773
+ raise ctypes.WinError()
773
774
  return buf.value[:length]
774
775
 
775
776
 
@@ -1179,6 +1180,10 @@ class IProvideClassInfo(IUnknown):
1179
1180
  ]
1180
1181
 
1181
1182
 
1183
+ # Flags used to specify the kind of information requested from an object.
1184
+ GUIDKIND_DEFAULT_SOURCE_DISP_IID = 1
1185
+
1186
+
1182
1187
  class IProvideClassInfo2(IProvideClassInfo):
1183
1188
  _iid_ = GUID("{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}")
1184
1189
  if TYPE_CHECKING:
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: comtypes
3
- Version: 1.4.10
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
@@ -17,6 +17,7 @@ Requires-Python: >=3.8
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE.txt
19
19
  Dynamic: download-url
20
+ Dynamic: license-file
20
21
 
21
22
  # comtypes
22
23
 
@@ -93,9 +93,11 @@ comtypes/test/test_dispifc_records.py
93
93
  comtypes/test/test_dispifc_safearrays.py
94
94
  comtypes/test/test_dispinterface.py
95
95
  comtypes/test/test_dyndispatch.py
96
+ comtypes/test/test_errorinfo.py
96
97
  comtypes/test/test_excel.py
97
98
  comtypes/test/test_findgendir.py
98
99
  comtypes/test/test_getactiveobj.py
100
+ comtypes/test/test_hresult.py
99
101
  comtypes/test/test_ie.py
100
102
  comtypes/test/test_ienum.py
101
103
  comtypes/test/test_imfattributes.py
@@ -11,20 +11,15 @@ ignore = ["E402"]
11
11
  "comtypes/_npsupport.py" = ["F401"]
12
12
  "comtypes/_vtbl.py" = ["E722"]
13
13
  "comtypes/automation.py" = ["F401", "F403", "F405"]
14
- "comtypes/connectionpoints.py" = ["F401", "F403", "F405"]
15
- "comtypes/errorinfo.py" = ["F403", "F405"]
16
14
  "comtypes/git.py" = ["F401", "F403", "F405"]
17
15
  "comtypes/util.py" = ["F403", "F405"]
18
16
  "comtypes/viewobject.py" = ["F403", "F405"]
19
- "comtypes/client/_code_cache.py" = ["E401", "E711"]
20
17
  "comtypes/client/_constants.py" = ["F401"]
21
- "comtypes/client/_events.py" = ["F841"]
22
18
  "comtypes/server/automation.py" = ["F403", "F405"]
23
19
  "comtypes/server/connectionpoints.py" = ["F401", "F403", "F405"]
24
- "comtypes/server/inprocserver.py" = ["E713", "E722", "F841"]
20
+ "comtypes/server/inprocserver.py" = ["E722"]
25
21
  "comtypes/server/register.py" = ["E713"]
26
22
  "comtypes/tools/codegenerator/packing.py" = ["F821", "F841"]
27
- "comtypes/tools/tlbparser.py" = ["F401"]
28
23
  "comtypes/tools/typedesc.py" = ["F403", "F405"]
29
24
  "comtypes/tools/typedesc_base.py" = ["F401"]
30
25
  # gen directory
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes