How can I access errno from Python's CFFI?

461 views Asked by At

I'm using cffi to wrap a library that uses errno to return error values.

How can I read errno from cffi?

1

There are 1 answers

0
Paul Rooney On BEST ANSWER

See docs https://cffi.readthedocs.org/en/release-0.6/

ffi.errno is a property of the cffi.FFI object.

e.g.

from cffi import FFI    
ffi = FFI()
# error happens
print ffi.errno

ffi.errno: the value of errno received from the most recent C call in this thread, and passed to the following C call, is available via reads and writes of the property ffi.errno. On Windows we also save and restore the GetLastError() value, but to access it you need to declare and call the GetLastError() function as usual.