-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove the outdated bridge for GUID.binary
#388
Comments
Note for reminder of similar cases. This *DOES NOT* mean to include them in the scope of this issue. memoNo.before #427Lines 1 to 2 in 12d22a2
after #427Lines 1 to 2 in 558f4e5
|
elif what == "DISPPROPERTY": | |
# DISPPROPERTY have implicit "out" | |
if restype: | |
argspec += ((['out'], restype, ""),) | |
self.__make_dispentry(finder, interface, | |
"_get_" + mthname, | |
idlflags, argspec, | |
2 # DISPATCH_PROPERTYGET | |
) | |
if not 'readonly' in idlflags: | |
self.__make_dispentry(finder, interface, | |
"_set_" + mthname, | |
idlflags, argspec, | |
4) # DISPATCH_PROPERTYPUT | |
# Add DISPATCH_PROPERTYPUTREF also? |
after #427
comtypes/comtypes/_comobject.py
Lines 538 to 553 in 558f4e5
elif what == "DISPPROPERTY": | |
# DISPPROPERTY have implicit "out" | |
if restype: | |
argspec += ((["out"], restype, ""),) | |
self.__make_dispentry( | |
finder, | |
interface, | |
"_get_" + mthname, | |
idlflags, | |
argspec, | |
2, # DISPATCH_PROPERTYGET | |
) | |
if not "readonly" in idlflags: | |
self.__make_dispentry( | |
finder, interface, "_set_" + mthname, idlflags, argspec, 4 | |
) # DISPATCH_PROPERTYPUT |
comtypes/_memberspec.py
No.1
before #427
comtypes/comtypes/_memberspec.py
Lines 101 to 102 in 12d22a2
for item in (self.restype, self.name, self.argtypes, self.paramflags, self.idlflags, self.doc): | |
yield item |
after #427
comtypes/comtypes/_memberspec.py
Lines 113 to 121 in 558f4e5
for item in ( | |
self.restype, | |
self.name, | |
self.argtypes, | |
self.paramflags, | |
self.idlflags, | |
self.doc, | |
): | |
yield item |
No.2
before #427
comtypes/comtypes/_memberspec.py
Line 213 in 12d22a2
self._data = {} # type: Dict[Tuple[str, Optional[str], int], List[Optional[Callable[..., Any]]]] |
after #427
comtypes/comtypes/_memberspec.py
Lines 235 to 237 in 558f4e5
self._data = ( | |
{} | |
) # type: Dict[Tuple[str, Optional[str], int], List[Optional[Callable[..., Any]]]] |
No.3
before #427
comtypes/comtypes/_memberspec.py
Line 344 in 12d22a2
self._mths = [] # type: List[Tuple[str, Callable[..., Any], Callable[..., Any], bool]] |
after #427
comtypes/comtypes/_memberspec.py
Lines 370 to 372 in 558f4e5
self._mths = ( | |
[] | |
) # type: List[Tuple[str, Callable[..., Any], Callable[..., Any], bool]] |
No.4
before #427
comtypes/comtypes/_memberspec.py
Line 388 in 12d22a2
self._items = [] # type: List[Tuple[str, _UnionT[Callable[..., Any], property], bool]] |
after #427
comtypes/comtypes/_memberspec.py
Lines 416 to 418 in 558f4e5
self._items = ( | |
[] | |
) # type: List[Tuple[str, _UnionT[Callable[..., Any], property], bool]] |
No.5
before #427
comtypes/comtypes/_memberspec.py
Lines 422 to 449 in 12d22a2
def _make_disp_method(self, m): | |
# type: (_DispMemberSpec) -> Callable[..., Any] | |
memid = m.memid | |
if "propget" in m.idlflags: | |
def getfunc(obj, *args, **kw): | |
return obj.Invoke(memid, _invkind=2, *args, **kw) # DISPATCH_PROPERTYGET | |
return getfunc | |
elif "propput" in m.idlflags: | |
def putfunc(obj, *args, **kw): | |
return obj.Invoke(memid, _invkind=4, *args, **kw) # DISPATCH_PROPERTYPUT | |
return putfunc | |
elif "propputref" in m.idlflags: | |
def putreffunc(obj, *args, **kw): | |
return obj.Invoke(memid, _invkind=8, *args, **kw) # DISPATCH_PROPERTYPUTREF | |
return putreffunc | |
# a first attempt to make use of the restype. Still, support for | |
# named arguments and default argument values should be added. | |
if hasattr(m.restype, "__com_interface__"): | |
interface = m.restype.__com_interface__ # type: ignore | |
def comitffunc(obj, *args, **kw): | |
result = obj.Invoke(memid, _invkind=1, *args, **kw) | |
if result is None: | |
return | |
return result.QueryInterface(interface) | |
return comitffunc | |
def func(obj, *args, **kw): | |
return obj.Invoke(memid, _invkind=1, *args, **kw) # DISPATCH_METHOD | |
return func |
after #427
comtypes/comtypes/_memberspec.py
Lines 456 to 499 in 558f4e5
def _make_disp_method(self, m): | |
# type: (_DispMemberSpec) -> Callable[..., Any] | |
memid = m.memid | |
if "propget" in m.idlflags: | |
def getfunc(obj, *args, **kw): | |
return obj.Invoke( | |
memid, _invkind=2, *args, **kw | |
) # DISPATCH_PROPERTYGET | |
return getfunc | |
elif "propput" in m.idlflags: | |
def putfunc(obj, *args, **kw): | |
return obj.Invoke( | |
memid, _invkind=4, *args, **kw | |
) # DISPATCH_PROPERTYPUT | |
return putfunc | |
elif "propputref" in m.idlflags: | |
def putreffunc(obj, *args, **kw): | |
return obj.Invoke( | |
memid, _invkind=8, *args, **kw | |
) # DISPATCH_PROPERTYPUTREF | |
return putreffunc | |
# a first attempt to make use of the restype. Still, support for | |
# named arguments and default argument values should be added. | |
if hasattr(m.restype, "__com_interface__"): | |
interface = m.restype.__com_interface__ # type: ignore | |
def comitffunc(obj, *args, **kw): | |
result = obj.Invoke(memid, _invkind=1, *args, **kw) | |
if result is None: | |
return | |
return result.QueryInterface(interface) | |
return comitffunc | |
def func(obj, *args, **kw): | |
return obj.Invoke(memid, _invkind=1, *args, **kw) # DISPATCH_METHOD | |
return func |
comtypes/client/_generate.py
No.1
before #427
comtypes/comtypes/client/_generate.py
Lines 155 to 158 in 12d22a2
with winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, r"CLSID\%s\TypeLib" % clsid) as key: | |
libid = winreg.EnumValue(key, 0)[1] | |
with winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, r"CLSID\%s\Version" % clsid) as key: | |
ver = winreg.EnumValue(key, 0)[1].split(".") |
after #427
comtypes/comtypes/client/_generate.py
Lines 159 to 166 in 558f4e5
with winreg.OpenKey( | |
winreg.HKEY_CLASSES_ROOT, r"CLSID\%s\TypeLib" % clsid | |
) as key: | |
libid = winreg.EnumValue(key, 0)[1] | |
with winreg.OpenKey( | |
winreg.HKEY_CLASSES_ROOT, r"CLSID\%s\Version" % clsid | |
) as key: | |
ver = winreg.EnumValue(key, 0)[1].split(".") |
comtypes/client/dynamic.py
No.1
before #427
comtypes/comtypes/client/dynamic.py
Line 61 in 12d22a2
self.__dict__["_ids"] = {} # Tiny optimization: trying not to use GetIDsOfNames more than once |
after #427
comtypes/comtypes/client/dynamic.py
Lines 71 to 73 in 558f4e5
self.__dict__[ | |
"_ids" | |
] = {} # Tiny optimization: trying not to use GetIDsOfNames more than once |
comtypes/test/test_excel.py
No.1
before #427
comtypes/comtypes/test/test_excel.py
Line 50 in 12d22a2
xl.Range["A1", "C1"].Value[()] = (10,"20",31.4) # XXX: in Python >= 3.8.x, cannot set values to A1:C1 |
after #427
comtypes/comtypes/test/test_excel.py
Lines 51 to 55 in 558f4e5
xl.Range["A1", "C1"].Value[()] = ( | |
10, | |
"20", | |
31.4, | |
) # XXX: in Python >= 3.8.x, cannot set values to A1:C1 |
related: python/cpython#99952, python/cpython#100169
comtypes/test/test_word.py
No.1
before #427
comtypes/comtypes/test/test_word.py
Line 8 in 12d22a2
comtypes.client.GetModule(('{00020905-0000-0000-C000-000000000046}',)) # Word libUUID |
after #427
comtypes/comtypes/test/test_word.py
Lines 8 to 10 in 558f4e5
comtypes.client.GetModule( | |
("{00020905-0000-0000-C000-000000000046}",) | |
) # Word libUUID |
comtypes/tools/codegenerator.py
No.1
before #427
comtypes/comtypes/tools/codegenerator.py
Lines 166 to 174 in 12d22a2
def name_wrapper_module(tlib): | |
"""Determine the name of a typelib wrapper module""" | |
libattr = tlib.GetLibAttr() | |
modname = "_%s_%s_%s_%s" % \ | |
(str(libattr.guid)[1:-1].replace("-", "_"), | |
libattr.lcid, | |
libattr.wMajorVerNum, | |
libattr.wMinorVerNum) | |
return "comtypes.gen.%s" % modname |
after #427
comtypes/comtypes/tools/codegenerator.py
Lines 179 to 188 in 558f4e5
def name_wrapper_module(tlib): | |
"""Determine the name of a typelib wrapper module""" | |
libattr = tlib.GetLibAttr() | |
modname = "_%s_%s_%s_%s" % ( | |
str(libattr.guid)[1:-1].replace("-", "_"), | |
libattr.lcid, | |
libattr.wMajorVerNum, | |
libattr.wMinorVerNum, | |
) | |
return "comtypes.gen.%s" % modname |
No.2
before #427
comtypes/comtypes/tools/codegenerator.py
Lines 261 to 272 in 12d22a2
def _make_withargs(self): | |
# type: () -> None | |
code = ( | |
" COMMETHOD(\n" | |
" %r,\n" | |
" %s,\n" | |
" '%s'," | |
) % self._get_common_elms() | |
print(code, file=self._stream) | |
arglist = [_to_arg_definition(*i) for i in self._iter_args()] | |
print(",\n".join(arglist), file=self._stream) | |
print(" ),", file=self._stream) |
after #427
comtypes/comtypes/tools/codegenerator.py
Lines 276 to 284 in 558f4e5
def _make_withargs(self): | |
# type: () -> None | |
code = ( | |
" COMMETHOD(\n" " %r,\n" " %s,\n" " '%s'," | |
) % self._get_common_elms() | |
print(code, file=self._stream) | |
arglist = [_to_arg_definition(*i) for i in self._iter_args()] | |
print(",\n".join(arglist), file=self._stream) | |
print(" ),", file=self._stream) |
No.3
before #427
comtypes/comtypes/tools/codegenerator.py
Lines 370 to 381 in 12d22a2
def _make_withargs(self): | |
# type: () -> None | |
code = ( | |
" DISPMETHOD(\n" | |
" %r,\n" | |
" %s,\n" | |
" '%s'," | |
) % self._get_common_elms() | |
print(code, file=self._stream) | |
arglist = [_to_arg_definition(*i) for i in self._iter_args()] | |
print(",\n".join(arglist), file=self._stream) | |
print(" ),", file=self._stream) |
after #427
comtypes/comtypes/tools/codegenerator.py
Lines 382 to 390 in 558f4e5
def _make_withargs(self): | |
# type: () -> None | |
code = ( | |
" DISPMETHOD(\n" " %r,\n" " %s,\n" " '%s'," | |
) % self._get_common_elms() | |
print(code, file=self._stream) | |
arglist = [_to_arg_definition(*i) for i in self._iter_args()] | |
print(",\n".join(arglist), file=self._stream) | |
print(" ),", file=self._stream) |
No.4
before #427
comtypes/comtypes/tools/codegenerator.py
Line 1057 in 12d22a2
print("################################################################", file=self.stream) |
after #427
comtypes/comtypes/tools/codegenerator.py
Lines 1113 to 1116 in 558f4e5
print( | |
"################################################################", | |
file=self.stream, | |
) |
No.5
before #427
comtypes/comtypes/tools/codegenerator.py
Lines 1268 to 1274 in 12d22a2
class ImportedNamespaces(object): | |
def __init__(self): | |
if sys.version_info >= (3, 7): | |
self.data = {} | |
else: | |
from collections import OrderedDict | |
self.data = OrderedDict() |
after #427
comtypes/comtypes/tools/codegenerator.py
Lines 1351 to 1358 in 558f4e5
class ImportedNamespaces(object): | |
def __init__(self): | |
if sys.version_info >= (3, 7): | |
self.data = {} | |
else: | |
from collections import OrderedDict | |
self.data = OrderedDict() |
No.6
before #427
comtypes/comtypes/tools/codegenerator.py
Lines 1350 to 1384 in 12d22a2
def _make_line(self, from_, imports, for_stub): | |
if for_stub: | |
import_ = ", ".join("%s as %s" % (n, n) for n in imports) | |
else: | |
import_ = ", ".join(imports) | |
code = "from %s import %s" % (from_, import_) | |
if len(code) <= 80: | |
return code | |
if for_stub: | |
import_ = "\n".join(" %s as %s," % (n, n) for n in imports) | |
else: | |
wrapper = textwrap.TextWrapper(subsequent_indent=" ", | |
initial_indent=" ", | |
break_long_words=False) | |
import_ = "\n".join(wrapper.wrap(import_)) | |
code = "from %s import (\n%s\n)" % (from_, import_) | |
return code | |
def getvalue(self, for_stub=False): | |
ns = {} | |
lines = [] | |
for key, val in self.data.items(): | |
if val is None: | |
ns[key] = val | |
elif key == "*": | |
lines.append("from %s import *" % val) | |
else: | |
ns.setdefault(val, set()).add(key) | |
for key, val in ns.items(): | |
if val is None: | |
lines.append("import %s" % key) | |
else: | |
names = sorted(val, key=lambda s: s.lower()) | |
lines.append(self._make_line(key, names, for_stub=for_stub)) | |
return "\n".join(lines) |
after #427
comtypes/comtypes/tools/codegenerator.py
Lines 1434 to 1468 in 558f4e5
def _make_line(self, from_, imports, for_stub): | |
if for_stub: | |
import_ = ", ".join("%s as %s" % (n, n) for n in imports) | |
else: | |
import_ = ", ".join(imports) | |
code = "from %s import %s" % (from_, import_) | |
if len(code) <= 80: | |
return code | |
if for_stub: | |
import_ = "\n".join(" %s as %s," % (n, n) for n in imports) | |
else: | |
wrapper = textwrap.TextWrapper( | |
subsequent_indent=" ", initial_indent=" ", break_long_words=False | |
) | |
import_ = "\n".join(wrapper.wrap(import_)) | |
code = "from %s import (\n%s\n)" % (from_, import_) | |
return code | |
def getvalue(self, for_stub=False): | |
ns = {} | |
lines = [] | |
for key, val in self.data.items(): | |
if val is None: | |
ns[key] = val | |
elif key == "*": | |
lines.append("from %s import *" % val) | |
else: | |
ns.setdefault(val, set()).add(key) | |
for key, val in ns.items(): | |
if val is None: | |
lines.append("import %s" % key) | |
else: | |
names = sorted(val, key=lambda s: s.lower()) | |
lines.append(self._make_line(key, names, for_stub=for_stub)) | |
return "\n".join(lines) |
No.7
before #427
comtypes/comtypes/tools/codegenerator.py
Lines 1387 to 1393 in 12d22a2
class DeclaredNamespaces(object): | |
def __init__(self): | |
if sys.version_info >= (3, 7): | |
self.data = {} | |
else: | |
from collections import OrderedDict | |
self.data = OrderedDict() |
after #427
comtypes/comtypes/tools/codegenerator.py
Lines 1471 to 1478 in 558f4e5
class DeclaredNamespaces(object): | |
def __init__(self): | |
if sys.version_info >= (3, 7): | |
self.data = {} | |
else: | |
from collections import OrderedDict | |
self.data = OrderedDict() |
comtypes/tools/tlbparser.py
No.1
before #427
comtypes/comtypes/tools/tlbparser.py
Lines 202 to 212 in 12d22a2
for i in range(ta.cVars): | |
vd = tinfo.GetVarDesc(i) | |
name = tinfo.GetDocumentation(vd.memid)[0] | |
offset = vd._.oInst * 8 | |
assert vd.varkind == typeinfo.VAR_PERINSTANCE | |
typ = self.make_type(vd.elemdescVar.tdesc, tinfo) | |
field = typedesc.Field(name, | |
typ, | |
None, # bits | |
offset) | |
members.append(field) |
after #427
comtypes/comtypes/tools/codegenerator.py
Lines 227 to 234 in 558f4e5
" '%s',\n" | |
" )" | |
) % elms | |
return code | |
class ComMethodGenerator(object): | |
def __init__(self, m, isdual): |
No.2
before #427
comtypes/comtypes/tools/tlbparser.py
Lines 548 to 558 in 12d22a2
for i in range(ta.cVars): | |
vd = tinfo.GetVarDesc(i) | |
name = tinfo.GetDocumentation(vd.memid)[0] | |
offset = vd._.oInst * 8 | |
assert vd.varkind == typeinfo.VAR_PERINSTANCE | |
typ = self.make_type(vd.elemdescVar.tdesc, tinfo) | |
field = typedesc.Field(name, | |
typ, | |
None, # bits | |
offset) | |
members.append(field) |
after #427
comtypes/comtypes/tools/tlbparser.py
Lines 606 to 612 in 558f4e5
for i in range(ta.cVars): | |
vd = tinfo.GetVarDesc(i) | |
name = tinfo.GetDocumentation(vd.memid)[0] | |
offset = vd._.oInst * 8 | |
assert vd.varkind == typeinfo.VAR_PERINSTANCE | |
typ = self.make_type(vd.elemdescVar.tdesc, tinfo) | |
field = typedesc.Field(name, typ, None, offset) # bits |
No.3
before #427
comtypes/comtypes/tools/tlbparser.py
Lines 722 to 727 in 12d22a2
if 0 == windll.oleaut32.QueryPathOfRegTypeLib(byref(la.guid), | |
la.wMajorVerNum, | |
la.wMinorVerNum, | |
0, # lcid | |
byref(name) | |
): |
after #427
comtypes/comtypes/tools/tlbparser.py
Lines 783 to 785 in 558f4e5
if 0 == windll.oleaut32.QueryPathOfRegTypeLib( | |
byref(la.guid), la.wMajorVerNum, la.wMinorVerNum, 0, byref(name) # lcid | |
): |
I close this because #449 is merged. |
THIS IS FOR
drop_py2
PLAN! Please see #392.Since
Release 1.0.0
,comtypes
dropped support for Python 2.5.But still exists a bridge for
GUID.binary
.comtypes/comtypes/GUID.py
Lines 4 to 9 in 0f3cf2b
Please fix as follows.
The text was updated successfully, but these errors were encountered: