mhammond / pywin32

Python for Windows (pywin32) Extensions
5.01k stars 793 forks source link

Exception handling code generates malformed EXCEPINFO struct #216

Closed ghost closed 6 years ago

ghost commented 19 years ago

In ErrorUtils.cpp, the PyCom_ExcepInfoFromPyException function does not zero out the EXCEPINFO structure with ZeroMemory or memset before filling in the data elements, and it does not fill all of them in. Because of this, the Python Active Scripting interface sends malformed errors to script hosts. In particular, the pfnDeferredFillIn member of the EXCEPINFO struct contains a random value. This member is a function pointer, and according to MS's documentation, the only way to prevent it from being called is to assign it a NULL value. The particular script hosting implementation I use attempts to call this pointer upon recieving any and all Python script errors, and the only fix I've been able to come up with is to ignore the field outright (which probably is not correct).

If this behavior is by design, any suggestions on a scripting host hack for dealing with this would be appreciated, so I can pass them on to the scripting host's author.

Reported by: janusfury

Original Ticket: "pywin32/bugs/216":https://sourceforge.net/p/pywin32/bugs/216

ghost commented 19 years ago

Logged In: YES user_id=14198

It sounds like you are correct. I have made the change here - would you be able to test this for me? If so, what Python version are you using?

Mark

Original comment by: mhammond

ghost commented 19 years ago

Logged In: YES user_id=313047

Sure, I'm using ActiveState Python 2.4.1 (iirc) and would be glad to test an updated version. I should be able to test it pretty easily by disabling the hack I added to get around the issue and seeing if it still works.

If I need to I can manually install vanilla Python 2.4 and then win32com, if ActiveState distributes a custom version.

Original comment by: janusfury

ghost commented 19 years ago

Logged In: YES user_id=14198

I can't recall from my mail - did you test my changes to this? If so, can you please close it?

Thanks

Original comment by: mhammond

ghost commented 19 years ago

Original comment by: janusfury

ghost commented 19 years ago

Logged In: YES user_id=313047

My bad! I thought the project maintainer was supposed to be the only one making changes like those.

Original comment by: janusfury