I have run across what I believe may be a shortcoming with win32com when trying to call functions that expect one-based indexed arrays as input.  The function I'm trying to invoke which demonstrates the problem is defined in my documentation as follows:
<br><span><br></span>HRESULT
SyncRead(<span><br></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [in]<span> </span>SHORT<span> </span><span></span>Source,<span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[in]<span> </span>LONG<span> </span>NumItems,
<span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[in]<span> </span>SAFEARRAY(LONG)
* ServerHandles,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span></span>[out]<span> </span>SAFEARRAY(VARIANT) * Values,<span></span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [out]<span> </span>SAFEARRAY(LONG) * Errors,<span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
[out,optional]<span> </span>VARIANT<span> </span>* Qualities,<span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[out,optional]<span> </span>VARIANT<span> </span>* TimeStamps);<br><br>In Python, this looks like:<br><br>server_handles = [16384,16385]
<br>num_items = 2<br>values, errors, qualities, timestamps = groups.SyncRead(2, num_items, server_handles)<br><br>

The num_items parameter is supposed to tell the function the total number sever_handles being passed in.&nbsp; Anyway, the above code always throws a com exception and fails.&nbsp; I am assuming this issue is due to the SyncRead function using one-based indexing for its array collection.
<br><br>However, if I append an extra &quot;dummy&quot; argument to the beginning of the server_handles list, it will always work.<br><br>server_handles = [0, 16384,16385]<br>
num_items = 2<br>
values, errors, qualities, timestamps = groups.SyncRead(2, num_items, server_handles)<br><br>The above example is a very poor solution since it appears to produce a slow memory leak in my application.&nbsp; Every 10 to 12 times the SyncRead call is invoked using the exact same server_handles, memory consumption increases by 4kb.&nbsp; This memory leak problem does not happen when called from VB.
<br><br>As an amusing test, I tried setting the variables passed to the function as follows:<br><br>server_handles = [0, 16384, 16385, 0, 0, 0, 0, 0, 0, 0, 0, 0]<br>num_items = 2<br><br>This makes an even bigger memory leak, leading me to believe any extra elements passed in the list beyond the num_items passed will always be allocated but never freed.
<br><br>Does Mark or anyone else know how to correctly pass a collection to a COM call using one-based indexing that won&#39;t cause a mem leak?&nbsp;&nbsp; I couldn&#39;t find any mention of this issue in the Python Win32 book other than an Excel example which didn&#39;t seem to apply.
<br><br>-BB<br><br>