Skip to content

Commit 9df846b

Browse files
authored
[mlir][python] fix PyThreadState_GetFrame (#153325)
`PyThreadState_GetFrame` wasn't added until 3.9 (fixes currently failing rocm builder)
1 parent 9e6b291 commit 9df846b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

mlir/lib/Bindings/Python/IRCore.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2786,6 +2786,14 @@ class PyOpAttributeMap {
27862786
PyOperationRef operation;
27872787
};
27882788

2789+
// bpo-40429 added PyThreadState_GetFrame() to Python 3.9.0b1
2790+
#if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION)
2791+
static inline PyFrameObject *PyThreadState_GetFrame(PyThreadState *tstate) {
2792+
assert(tstate != _Py_NULL);
2793+
return _Py_CAST(PyFrameObject *, Py_XNewRef(tstate->frame));
2794+
}
2795+
#endif
2796+
27892797
MlirLocation tracebackToLocation(MlirContext ctx) {
27902798
size_t framesLimit =
27912799
PyGlobals::get().getTracebackLoc().locTracebackFramesLimit();

0 commit comments

Comments
 (0)