如何从 Python 的 CFFI 访问 errno?

How can I access errno from Python's CFFI?

我正在使用 cffi 包装一个使用 errno 到 return 错误值的库。

如何从 cffi 读取 errno

查看文档 https://cffi.readthedocs.org/en/release-0.6/

ffi.errnocffi.FFI 对象的 属性。

例如

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.