David Wolever
David Wolever

Reputation: 154624

How can I access errno from Python's CFFI?

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

How can I read errno from cffi?

Upvotes: 3

Views: 475

Answers (1)

Paul Rooney
Paul Rooney

Reputation: 21619

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.

Upvotes: 3

Related Questions