ctypes errcheck question

B

Brendan Miller

According to the ctypes docs: http://docs.python.org/library/ctypes.html

An errcheck function should return the args tuple when used with out
parameters (section 15.15.2.4. Function prototypes). However, in other
cases it says to return the result, or whatever result you want
returned from the function.

I have a single errcheck function that checks result codes and throws
an exception if the result indicates an error. I'd like to reuse it
with a number of different function, some of which are specified with
out parameters, and some of which are specified in the normal method:

func = my_lib.func
func.restype = c_long
func.argtypes = [c_int, etc]

So, my question is can do I have my errcheck function return the args
tuple in both cases? The documentation seems kind of ambiguous about
how it will behave if a function loaded without output parameters
returns the arguments tuple from errcheck.

Thanks,
Brendan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top