Probable Pywin32 (win32com.client) bug??

N

neblackcat

This is a heads-up on a possible memory corruption type of bug in
recent and present versions of Python/win32com. I dont know if its
general, or specific to using win32com.client to access CDO as my
example does.

My script was tiny - it just opens a MAPI/CDO session and traverses
the email folders - but it keeps crashing Python at random places.

After 2 days of trying everything without success, I've finally
discovered that it depends on how I sequence through a (valid)
collection of folders returned by CDO:

If I do this:

for o in Folders:
....do something with the 'o' object...

Then the script seems to work OK, but it later crashes Python (in
CDO.DLL according to Windows). If it does crash, its always at the
same (unrelated) place in the script, though this changes "randomly"
whenever the script is changed or run in a different environment (eg.
IDE or command line). This suggests to me that there is some kind of
memory corruption going on.

But if I do this:

o = Folders.GetFirst()
while o:
....do something with the 'o' object...
o = Folders.GetNext()

Then the whole script works (the same) and is totally robust (no
Python crashes).

Could this be some kind of corruption going on within win32com when
the first technique is used? I've googled around, and as far as I can
see this is perfectly valid code.

Is this group the appropriate place to post this, eg. for Mark H to
see?

I have the whole 50-line script available if anyone else wants to try
this.

My system:
XP SP 1a
Outlook 2003 (with its CDO)
Python 2.3.2 (last ActiveState distribution) or 2.3.4
Pywin32 2.02 for Python 2.3
 

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,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top