Python COM - limit on size/complexity of returned object?

Paul Keating google at
Thu Jun 24 13:27:50 CEST 2004

I have a very simple COM server written in Python that is trying to
return a two-dimensional array 268 x 20. The values it contains are
some small integers, some short (<29 character) Unicode strings, and

To isolate the problem I have taken out the code that builds the
matrix from real data, and just substituted a literal tuple of tuples,
like this:

class AtlasSecurity:
  _reg_progid_ = 'Arena.Security'
  def GetProfileComponentMatrixEx(self):
#   self.BuildMatrix()
    self.matrix = ((u'ID', u'Name', u'Type', .... ),
    ... ))  # a 268-tuple of 20-tuples
    self.last_result = (self.matrix,)
    return self.last_result

Because I was having trouble calling it from Excel ("the server has
disconnected from its clients"), to see what was going on I decided to
call it from a Python client, like this:

from win32com.client import Dispatch
x = Dispatch("Arena.Security")
print x.GetProfileComponentMatrixEx()

This blows up in python22.dll with a C++ Runtime abort(), no matter
what I try. I can write a method that I can call 268 times to return
the data one 20-element vector at a time. This works, but is really
only good for simple data structures and I need this to work with
structures of arbitrary complexity and levels of nesting.

Is there a restriction on the size or complexity of the SafeArray that
pythoncom is constructing from the returned value? Or what else am I
doing wrong?

(I am using Python 2.2 because I am working with embedded Python and
that is the version that is embedded.)

More information about the Python-list mailing list