Message59835
> 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. |
|
Date |
User |
Action |
Args |
2008-01-12 19:56:55 | theller | set | spambayes_score: 0.00361788 -> 0.003617879 recipients:
+ theller, amaury.forgeotdarc |
2008-01-12 19:56:54 | theller | link | issue1798 messages |
2008-01-12 19:56:54 | theller | create | |
|