Thomas Heller added the comment: > But this thread-local attribute on the function seems bizarre to me. > I would prefer another way to get the errno. I can see two alternatives: > - the function returns a tuple (normalresult, errno) on each call. > - when errno is not zero, EnvironmentError (or WindowsError) is raised.
I'd stronly prefer NOT to add errno to the function return value. Raising an Exception when errno or LastError != zero is wrong. There are functions that set the errno or LastError value even if they actually succeed. The recommended way to check for errors that I had in mind is in the 'errcheck' result checker: func = CDLL(..., errno=True) func.argtypes = [...] func.restype = ... def errcheck(result, func, args): if result == -1: # function failed raise EnvironmentError(func.errno) func.errcheck = errcheck Of course, an alternative to a thread local storage attribute would be to pass the error value to the errcheck function. I just felt it would be better not to change the signature, but maybe I was wrong. Anyway, this patch should be extended so that it is also possible to create a foreign function using the descibed calling convention from a prototype created by CFUNCTYPE or WINFUNCTYPE. __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1798> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com