From 4c73a5e410060c68867c7846db4dfa354c07f19f Mon Sep 17 00:00:00 2001 From: junkmd Date: Fri, 23 Jan 2026 21:10:39 +0900 Subject: [PATCH] refactor: Unify COM descriptor release logic in `ITypeComp.Bind`. --- comtypes/typeinfo.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/comtypes/typeinfo.py b/comtypes/typeinfo.py index 52a20133..200d7ca6 100644 --- a/comtypes/typeinfo.py +++ b/comtypes/typeinfo.py @@ -445,16 +445,10 @@ def Bind( ) kind = desckind.value if kind == DESCKIND_FUNCDESC: - fd = bindptr.lpfuncdesc[0] - fd.__ref__ = weakref.ref( - fd, lambda dead: ti.ReleaseFuncDesc(bindptr.lpfuncdesc) - ) + fd = _deref_with_release(bindptr.lpfuncdesc, ti.ReleaseFuncDesc) return "function", fd elif kind == DESCKIND_VARDESC: - vd = bindptr.lpvardesc[0] - vd.__ref__ = weakref.ref( - vd, lambda dead: ti.ReleaseVarDesc(bindptr.lpvardesc) - ) + vd = _deref_with_release(bindptr.lpvardesc, ti.ReleaseVarDesc) return "variable", vd elif kind == DESCKIND_TYPECOMP: return "type", bindptr.lptcomp