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.
- {comtypes-1.4.10 → comtypes-1.4.11}/CHANGES.txt +22 -0
- {comtypes-1.4.10/comtypes.egg-info → comtypes-1.4.11}/PKG-INFO +3 -2
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/__init__.py +4 -4
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_comobject.py +23 -25
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_memberspec.py +100 -74
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_meta.py +1 -1
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_post_coinit/_cominterface_meta_patcher.py +3 -5
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_post_coinit/unknwn.py +29 -20
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_vtbl.py +52 -55
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/automation.py +9 -10
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_code_cache.py +9 -23
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_events.py +87 -49
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_generate.py +0 -2
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/connectionpoints.py +37 -3
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/errorinfo.py +53 -15
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/hints.pyi +15 -2
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/hresult.py +16 -6
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/messageloop.py +14 -12
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/connectionpoints.py +68 -67
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/inprocserver.py +8 -5
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/localserver.py +14 -20
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/register.py +2 -2
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_GUID.py +6 -7
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_basic.py +6 -3
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_collections.py +6 -3
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_comobject.py +19 -6
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_comserver.py +25 -2
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_dict.py +2 -1
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_dyndispatch.py +4 -2
- comtypes-1.4.11/comtypes/test/test_errorinfo.py +115 -0
- comtypes-1.4.11/comtypes/test/test_hresult.py +48 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_inout_args.py +9 -2
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_safearray.py +2 -1
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_server_register.py +2 -1
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_typeinfo.py +19 -2
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_variant.py +2 -1
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_w_getopt.py +4 -4
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/tlbparser.py +7 -6
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/typeinfo.py +14 -9
- {comtypes-1.4.10 → comtypes-1.4.11/comtypes.egg-info}/PKG-INFO +3 -2
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes.egg-info/SOURCES.txt +2 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/pyproject.toml +1 -6
- {comtypes-1.4.10 → comtypes-1.4.11}/LICENSE.txt +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/MANIFEST.in +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/README.md +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/GUID.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_npsupport.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_post_coinit/__init__.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_post_coinit/bstr.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_post_coinit/instancemethod.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_post_coinit/misc.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_safearray.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/_tlib_version_checker.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/clear_cache.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/__init__.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_activeobj.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_constants.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_create.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/_managing.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/dynamic.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/client/lazybind.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/git.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/logutil.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/patcher.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/persist.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/safearray.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/__init__.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/automation.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/server/w_getopt.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/shelllink.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/stream.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/TestComServer.idl +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/TestComServer.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/TestComServer.tlb +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/TestDispServer.idl +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/TestDispServer.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/TestDispServer.tlb +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/__init__.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/find_memleak.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/mylib.idl +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/mylib.tlb +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/mytypelib.idl +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/runtests.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/setup.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_BSTR.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_DISPPARAMS.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_QueryService.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_agilent.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_avmc.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_casesensitivity.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_clear_cache.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_client.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_client_dynamic.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_client_regenerate_modules.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_createwrappers.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_dispifc_records.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_dispifc_safearrays.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_dispinterface.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_excel.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_findgendir.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_getactiveobj.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_ie.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_ienum.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_imfattributes.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_jscript.js +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_midl_safearray_create.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_monikers.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_msscript.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_npsupport.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_outparam.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_persist.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_pump_events.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_recordinfo.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_sapi.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_server.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_shelllink.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_showevents.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_storage.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_stream.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_subinterface.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_typeannotator.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_urlhistory.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_win32com_interop.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_wmi.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/test_word.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/test/urlhist.tlb +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/__init__.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/__init__.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/codegenerator.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/comments.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/heads.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/helpers.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/modulenamer.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/namespaces.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/packing.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/codegenerator/typeannotator.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/typedesc.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/tools/typedesc_base.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/util.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes/viewobject.py +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes.egg-info/dependency_links.txt +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes.egg-info/entry_points.txt +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/comtypes.egg-info/top_level.txt +0 -0
- {comtypes-1.4.10 → comtypes-1.4.11}/setup.cfg +0 -0
- {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
|
|
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: "
|
|
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
|
|
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(
|
|
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,
|
|
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,
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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 =
|
|
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.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: comtypes
|
|
3
|
-
Version: 1.4.
|
|
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" = ["
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|