1

Maybe I'm missing something, but here is a problem:

I'm tracing python code by C extensions and my trace function got PyFrameObject* frame. Now I want to process the frame by Python code(embedded or converted to C by Cython) but it deals with PyObject*.

How do I convert PyFrameObject* to PyObject*? I don't find appropriate convertion funciton in frameobject.h.

Thanks.

1 Answer 1

2

Use a cast:

PyObject *myObject = (PyObject *)myFrameObject

This is standard for the Python C API; everything that "inherits" from PyObject has a PyObject_VAR_HEAD at the top of the object so a pointer to the object is convertible to a pointer to PyObject.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.