Skip to content

Commit dbbe37d

Browse files
committed
Merge branch 'main' of https://github.com/mhammond/pywin32 into repr-respect-subclass-name
2 parents 5523a2c + 16c4981 commit dbbe37d

File tree

15 files changed

+59
-11
lines changed

15 files changed

+59
-11
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ jobs:
157157
with:
158158
version: "0.8.4"
159159
- run: ruff format --check
160-
- run:
161-
| # Too many files to fit in a single command, also exclude vendored Scintilla and MAPIStubLibrary
160+
- run: | # Too many files to fit in a single command, also exclude vendored Scintilla and MAPIStubLibrary
162161
clang-format --Werror --dry-run $(git ls-files '*.cpp' ':!:com/win32comext/mapi/src/MAPIStubLibrary/')
163162
if ($LastExitCode -ne 0) { exit $LastExitCode }
164163
clang-format --Werror --dry-run $(git ls-files '*.h' ':!:Pythonwin/Scintilla/' ':!:com/win32comext/mapi/src/MAPIStubLibrary/')

CHANGES.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,18 @@ https://mhammond.github.io/pywin32_installers.html .
1414
Coming in build 311, as yet unreleased
1515
--------------------------------------
1616
* Fixed a regression that broke special __dunder__ methods with CoClass. (#1870, #2493, @Avasam, @geppi)
17+
* Fixed a memory leak when SafeArrays are used as out parameters (@the-snork)
1718
* Fixed dispatch handling for properties (@the-snork)
19+
* The following classes will now use the correct subclass name in `repr`: (#2570, @Avasam)
20+
* `pywin.tools.browser.HLIPythonObject`
21+
* `win32com.client.VARIANT`
22+
* `win32com.client.build.MapEntry`
23+
* `win32com.server.exception.COMException`
24+
* `win32comext.axdebug.debugger.ModuleTreeNode`
25+
* `win32comext.axscript.client.pyscript.NamedScriptAttribute`
26+
* `win32comext.axscript.client.error.AXScriptException`
27+
* `win32pdhquery.QueryError`
28+
* `win32rcparser.StringDef`
1829

1930
Build 310, released 2025/03/16
2031
------------------------------

com/TestSources/PyCOMTest/PyCOMImpl.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,13 @@ STDMETHODIMP CPyCOMTest::GetSafeArrays(SAFEARRAY **attrs, SAFEARRAY **attrs2, SA
379379
return S_OK;
380380
}
381381

382+
STDMETHODIMP CPyCOMTest::GetByteArray(long sizeBytes, SAFEARRAY **array)
383+
{
384+
SAFEARRAYBOUND bound = {static_cast<ULONG>(sizeBytes), 0};
385+
*array = SafeArrayCreate(VT_UI1, 1, &bound);
386+
return S_OK;
387+
}
388+
382389
STDMETHODIMP CPyCOMTest::GetSimpleSafeArray(SAFEARRAY **attrs) { return MakeFillIntArray(attrs, 10, VT_I4); }
383390

384391
STDMETHODIMP CPyCOMTest::CheckVariantSafeArray(SAFEARRAY **attrs, int *result)

com/TestSources/PyCOMTest/PyCOMImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class CPyCOMTest : public IDispatchImpl<IPyCOMTest, &IID_IPyCOMTest, &LIBID_PyCO
8080
STDMETHOD(SetDoubleSafeArray)(SAFEARRAY *vars, int *retSize);
8181
STDMETHOD(SetFloatSafeArray)(SAFEARRAY *vars, int *retSize);
8282
STDMETHOD(GetSafeArrays)(SAFEARRAY **attrs, SAFEARRAY **attrs2, SAFEARRAY **ints);
83+
STDMETHOD(GetByteArray)(long sizeBytes, SAFEARRAY **array);
8384
STDMETHOD(GetSimpleSafeArray)(SAFEARRAY **ints);
8485
STDMETHOD(ChangeDoubleSafeArray)(SAFEARRAY **vals);
8586
STDMETHOD(GetSimpleCounter)(ISimpleCounter **counter);

com/TestSources/PyCOMTest/PyCOMTest.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ library PyCOMTestLib
235235
HRESULT GetSafeArrays([out] SAFEARRAY(QsAttribute)* attrs,
236236
[out] SAFEARRAY(enum tagQsAttribute)*attrs2,
237237
[out] SAFEARRAY(int)*ints);
238+
HRESULT GetByteArray([in] long sizeInBytes, [out] SAFEARRAY(byte) *bytes);
238239
HRESULT ChangeDoubleSafeArray([in, out]SAFEARRAY(double)*vals);
239240
HRESULT GetSimpleCounter([out, retval] ISimpleCounter** counter);
240241
HRESULT CheckVariantSafeArray([in] SAFEARRAY(VARIANT)* data, [out, retval]int *sum);

com/TestSources/PyCOMTest/PyCOMTest.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,4 @@
161161
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
162162
<ImportGroup Label="ExtensionTargets">
163163
</ImportGroup>
164-
</Project>
164+
</Project>

com/win32com/client/combrowse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import sys
2727

2828
import pythoncom
29+
import pywintypes
2930
import win32api
3031
import win32con
3132
import win32ui
@@ -61,7 +62,7 @@ def CalculateIsExpandable(self):
6162
class HLICLSID(HLICOM):
6263
def __init__(self, myobject, name=None):
6364
if isinstance(myobject, str):
64-
myobject = pythoncom.MakeIID(myobject)
65+
myobject = pywintypes.IID(myobject)
6566
if name is None:
6667
try:
6768
name = pythoncom.ProgIDFromCLSID(myobject)

com/win32com/demos/connect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
# is cheated on - so this is still working as a fully-fledged server.
77

88
import pythoncom
9+
import pywintypes
910
import win32com.server.connect
1011
import win32com.server.util
1112

1213
# This is the IID of the Events interface both Client and Server support.
13-
IID_IConnectDemoEvents = pythoncom.MakeIID("{A4988850-49C3-11d0-AE5D-52342E000000}")
14+
IID_IConnectDemoEvents = pywintypes.IID("{A4988850-49C3-11d0-AE5D-52342E000000}")
1415

1516
# The server which implements
1617
# Create a connectable class, that has a single public method

com/win32com/server/policy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def _wrap_(self, object):
257257
if i[0] != "{":
258258
i = pythoncom.InterfaceNames[i]
259259
else:
260-
i = pythoncom.MakeIID(i)
260+
i = pywintypes.IID(i)
261261
self._com_interfaces_.append(i)
262262
else:
263263
self._com_interfaces_ = []

com/win32com/src/PyIDispatch.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,12 @@ PyObject *PyIDispatch::InvokeTypes(PyObject *self, PyObject *args)
517517

518518
error:
519519
if (dispparams.rgvarg) {
520-
for (i = dispparams.cArgs; i--;) VariantClear(&dispparams.rgvarg[i]);
520+
for (i = dispparams.cArgs; i--;) {
521+
if ((V_VT(&dispparams.rgvarg[i]) & ~VT_TYPEMASK) == (VT_BYREF | VT_ARRAY)) {
522+
SafeArrayDestroy(*V_ARRAYREF(&dispparams.rgvarg[i]));
523+
}
524+
VariantClear(&dispparams.rgvarg[i]);
525+
}
521526
delete[] dispparams.rgvarg;
522527
}
523528
delete[] ArgHelpers;

0 commit comments

Comments
 (0)