Arbitrary errors with c++, python, and simple mapi

T

Thomas Zehbe

Hi all,
I´m programming a wxWidgets application using MSVC++ 6.0 on WinXp, SP1,
reportlab 1.19 and simple mapi.

I programmend python modules, which call the reportlab modules. My python
modules are called from C++ using the API.
Everything works fine until I did the first call to a function in the
mapi32.dll. The loading of the dll doesn´t matter, but any call to the mapi,
i.E. MAPLogon, leads to arbitrary errors calling the Py-API.
Example.
pDict = PyModule_GetDict(pModule);
pFunc = PyDict_GetItemString(pDict, func);
Doing this before a mapi call and calling PyDict_Keys(pDict) returns a list of
91 keys including the function func. Doing it after a mapi call
PyDict_Keys(pDict) returns a list of only 15 Keys without the function func.
Doing the calls before and after a mapi call, a callable pFunc is returned in
both cases, but the pFunc retrieved after the mapi call doesn´t work anymore.
Calling
pValue = PyObject_CallObject(pFunc, pArgs);
returns 0x0 and no pdf file is generated.

Seems that the MS dlls are peeking and poking around in the python
interpreter memory.

Has anybody seen this happen, too? How can I debug it. All print statements
from within the python modules seem to go to /dev/null, as do
if (pErr = PyErr_Occurred())
PyErr_Print();
Any help would be appreciated.
Thanks
Thomas
--
Thomas Zehbe

INGENION GmbH
Luther Weg 50
31515 Wunstorf

Tel 05031-902042
Fax 05031-902049
www.ingenion.de
 
A

Amanjit Gill

Thomas Zehbe wrote:

Everything works fine until I did the first call to a function in the
mapi32.dll. The loading of the dll doesn´t matter, but any call to the mapi,
i.E. MAPLogon, leads to arbitrary errors calling the Py-API.
[..]

Hi,

- I suppose you should first check if your heap is still ok - perhaps
your usage of that specific DLL caused heap corruption. Then the py-API
screwed up. You should try the following standard heap check from win32
(<crtdbg.h>, _DEBUG versions)

_CrtCheckMemory() // to check all of the heap
_CrtIsValidPointer(..) // to check a specific memory region for r/w

doing _CrtCheckMemory() before and after a call can reveal alot.

- It is very important to use the same runtime library in your projects,
this is another common cause for failure.

- MAPI is a COM library. You might try this straight c++ wrapper class
first and see if the simplest example works for you:
http://www.codeproject.com/internet/mapadmin.asp#xx708710xx. Or you may
aswell try the more simplistic CMC Common messaging calls first
(Platform SDK).

Sorry for being _UnPythonic();

_________________________
Amanjit Gill
Medical and Bioinformatics
Gynecology and Obstetrics
University Clinic Charite
Berlin, Germany

(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top