小编Nic*_*tti的帖子

用于计算第一组和后续组的工具/应用程序

我目前正在研究一个解析器,看起来我犯了一些错误,因为我不知道如何计算.所以我想知道是否有人知道计算跟随和第一组的好工具,所以我可以跳过/重新评估解析器构造中这个容易出错的部分.

grammar parsing

12
推荐指数
2
解决办法
1万
查看次数

如何在 python 中获取 errno 值的错误消息?

我正在使用ctypes模块在 Linux 上执行一些 ptrace 系统调用,实际上效果很好。但如果我遇到错误,我想提供一些有用的信息。因此,我执行了get_errno()函数调用,它返回 errno 的值,但我没有找到任何函数或其他东西来解释 errno 值并给我相关的错误消息。

我错过了什么吗?有基于ctypes的解决方案吗?

这是我的设置:

import logging
from ctypes import get_errno, cdll
from ctypes.util import find_library, errno

# load the c lib
libc = cdll.LoadLibrary(find_library("c"), use_errno=True)
...
Run Code Online (Sandbox Code Playgroud)

例子:

 return_code = libc.ptrace(PTRACE_ATTACH, pid, None, None)
 if return_code == -1:
   errno = get_errno()
   error_msg = # here i wanna provide some information about the error
   logger.error(error_msg)
Run Code Online (Sandbox Code Playgroud)

python linux ctypes errno system-calls

6
推荐指数
1
解决办法
5369
查看次数

标签 统计

ctypes ×1

errno ×1

grammar ×1

linux ×1

parsing ×1

python ×1

system-calls ×1