On 13/04/2011 2:14 AM, Chris Frantz wrote:
Hello,

I'm having a bit of trouble with ReportEvent: When I use a large value
for eventID, I get an OverflowError.

 >>> import win32evtlogutil
 >>> win32evtlogutil.ReportEvent('FooBar', 0xc0004652)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "c:\python26\lib\site-packages\win32\lib\win32evtlogutil.py",
line 80, in ReportEvent
     data)
OverflowError: long int too large to convert to int

Yeah - this is a bug in the general DWORD handling in SWIG generated files. I'm not sure how to tell SWIG to use a different format char, but I have managed to work around it in other ways which is good for the general case.

However, in this case specifically, it doesn't seem to work as intended. After fixing it, the Event Viewer shows the event ID is actually 18002 - which is 0xc0004652 with the 2 most significant bits reset to zero. Digging deeper, the docs at http://msdn.microsoft.com/en-us/library/aa363651%28v=vs.85%29.aspx imply those 2 bits are used to record the severity of the message. It appears the function will mask out those bits according to the other params passed to ReportEvent, meaning you can't wind up with such an event ID in the event viewer anyway...

But this consideration is specific to ReportEvent - so the next pywin32 build will allow DWORD params in SWIG wrappers to pass such integers without error - but it seems that wont actually help your problem.

Cheers,

Mark
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to