[mlir][python] fix PyThreadState_GetFrame (#153325)

`PyThreadState_GetFrame` wasn't added until 3.9 (fixes currently failing
rocm builder)
This commit is contained in:
Maksim Levental
2025-08-12 21:16:04 -04:00
committed by GitHub
parent 9e6b29137b
commit 9df846bf71

View File

@@ -2786,6 +2786,14 @@ private:
PyOperationRef operation;
};
// bpo-40429 added PyThreadState_GetFrame() to Python 3.9.0b1
#if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION)
static inline PyFrameObject *PyThreadState_GetFrame(PyThreadState *tstate) {
assert(tstate != _Py_NULL);
return _Py_CAST(PyFrameObject *, Py_XNewRef(tstate->frame));
}
#endif
MlirLocation tracebackToLocation(MlirContext ctx) {
size_t framesLimit =
PyGlobals::get().getTracebackLoc().locTracebackFramesLimit();