[Python-Dev] FormatError() in callproc.c under win32

Ulrich Eckhardt eckhardt at satorlaser.com
Mon Jan 26 19:04:17 CET 2009


Hi!

In callproc.c from trunk is a function called SetException(), which calls 
FormatError() only to discard the contents. Can anyone enlighten me to the 
reasons thereof? Is it just to check if the errorcode is registered in the 
stringtables?

The reason I ask is the CE port. The FormatMessage API exists there (or, 
rather, the FormatMessageW API), but the tables containing the error messages 
are optional for the OS and for space reasons many vendors chose not to 
include them. That means that the function there regularly fails to retrieve 
the requested string.

My first approach was to fall back to simply providing a sting with a numeric 
representation of the errorcode, but that would change the meaning of above 
function, because then it could never fails.

My second approach was to enhance PyErr_SetFromWindowsErr() to handle the 
additional error codes that are checked in SetException(). However, those 
require more context than just the error code, they use the EXCEPTION_RECORD 
passed to SetException() for that.

My third approach would be to filter out the special error codes first and 
delegate all others to PyErr_SetFromWindowsErr(). The latter already handles 
the lack of a string for the code by formatting it numerically. This would 
also improve consistency, since the two functions use different ways to 
format unrecognised errors numerically. This approach would change where and 
how a completely unrecognised error code is formatted, but would otherwise be 
pretty equivalent.


Suggestions?

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

**************************************************************************************
Sator Laser GmbH, Fangdieckstraße 75a, 22547 Hamburg, Deutschland
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
**************************************************************************************
           Visit our website at <http://www.satorlaser.de/>
**************************************************************************************
Diese E-Mail einschließlich sämtlicher Anhänge ist nur für den Adressaten bestimmt und kann vertrauliche Informationen enthalten. Bitte benachrichtigen Sie den Absender umgehend, falls Sie nicht der beabsichtigte Empfänger sein sollten. Die E-Mail ist in diesem Fall zu löschen und darf weder gelesen, weitergeleitet, veröffentlicht oder anderweitig benutzt werden.
E-Mails können durch Dritte gelesen werden und Viren sowie nichtautorisierte Änderungen enthalten. Sator Laser GmbH ist für diese Folgen nicht verantwortlich.
**************************************************************************************



More information about the Python-Dev mailing list