【问题标题】:How can I access errno from Python's CFFI?如何从 Python CFFI 访问错误?
【发布时间】:2015-08-24 22:17:42
【问题描述】:

我正在使用cffi 包装一个库,该库使用errno 返回错误值。

如何从 cffi 读取errno

【问题讨论】:

  • Docs 表示ffi.errno,其中fficffi.FFI() 的实例。
  • 天啊!奇怪的是,这仅在更改日志中。你能把它作为一个答案让我接受吗?

标签: python python-cffi


【解决方案1】:

请参阅文档https://cffi.readthedocs.org/en/release-0.6/

ffi.errnocffi.FFI 对象的属性。

例如

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

ffi.errno:从该线程中最近的 C 调用接收的 errno 的值,并传递给下一个 C 调用,可通过属性 ffi.errno 的读取和写入获得。在 Windows 上,我们还保存和恢复 GetLastError() 值,但要访问它,您需要像往常一样声明并调用 GetLastError() 函数。

【讨论】:

    猜你喜欢
    • 2020-10-25
    • 2015-01-29
    • 2013-09-04
    • 2021-10-06
    • 2016-01-20
    • 2018-08-21
    • 2016-07-17
    • 2011-04-01
    • 2014-07-30
    相关资源
    最近更新 更多