Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个用 C++ 编写的 python 解释器,据说来自 Python API 的 PyRun_String 函数返回一个句柄,但是在我的代码中,我将它分配给指向一个PyObject?
PyObject
PyObject* presult = PyRun_String(code, parse_mode, dict, dict);
这真的正确吗?您可以将此句柄隐式转换为该对象指针吗?
它不应该是 HANDLE 吗?
API 文档中的“句柄”一词通常并不专门指代HANDLE类型,而是指任何对用户不透明的类型。
HANDLE
PyRun_String特别是返回 a PyObject*,没有强制转换。
PyRun_String
PyObject*