Skip to content

Conversation

@makslevental
Copy link
Contributor

PyThreadState_GetFrame wasn't added until 3.9 (fixes currently failing rocm builder)

@makslevental makslevental enabled auto-merge (squash) August 13, 2025 01:01
@llvmbot llvmbot added the mlir label Aug 13, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 13, 2025

@llvm/pr-subscribers-mlir

Author: Maksim Levental (makslevental)

Changes

PyThreadState_GetFrame wasn't added until 3.9 (fixes currently failing rocm builder)


Full diff: https://github.com/llvm/llvm-project/pull/153325.diff

1 Files Affected:

  • (modified) mlir/lib/Bindings/Python/IRCore.cpp (+8)
diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index 1aec7ffe8e083..03b04ffbe9749 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -2786,6 +2786,14 @@ class PyOpAttributeMap {
   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();

@makslevental makslevental merged commit 9df846b into llvm:main Aug 13, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants