[python-win32] Variant ByRef 2D array returned as 1D array

Kevin Patterson patter001 at gmail.com
Wed Aug 16 18:17:21 CEST 2006


win32com is definitely treating it as a string (or byte buffer), but I
would have expected to get a byte buffer with the data for ALL the
elements. For example the array being returned should be 30x8 array,
but i get a string with a length of 30 instead of a string of length
30*8. Does the pythoncom know to traverse both arrays and convert in
to one big buffer? Seems like I'm getting only the first element of
each entry in the 30x8 array.  Juduging from your statement I think
the fact that its a buffer (instead of a 2D list) is ok, but I should
be getting a buffer of lenghth = 30x8 instead of just 30.

Thanks for the offer of help, I'll fight some guys on my end to reduce
the code down and see what I get :) The problem occurs both on the
read and write. In other words: I can't seem to write a 2D array back
in to the COM module by refrence either, so hopefully the writers of
the COM can also tell me what data they are getting versus what they
are expecting to help pinpoint the problem.

On 8/16/06, Mark Hammond <mhammond at skippinet.com.au> wrote:
> > I'm working with a COM module that is returning a 2D array as a
> > VARIANT BYREF. The 2D array is 30x8 (with each entry being 1 byte)
> > When the data is returned I'm getting a buffer of length 30. This
> > tells me that win32com only sees 1D of the array (documentation states
> > that the buffer is expected for variants-byref with entries of 1
> > byte). Any ideas on why win32com doesn't see that there is really an
> > array of arrays?
>
> If the type of one dimension is VT_UI8, then pythoncom will treat that as a
> 'byte buffer', so will return a string - in which case you will simply need
> to pretend the string is actually an array of bytes!  Otherwise you are
> probably going to need to help create a test case so I can see exactly what
> is going on - what language is this object implemented in, and is the source
> available?  We have test COM objects written in VB and C, so creating a test
> case shouldn't be too hard.
>
> Cheers,
>
> Mark
>
>


More information about the Python-win32 mailing list