[mlir][Python] Drop Python <=3.9 compatibility path - #183416
Merged
Merged
Conversation
Member
|
@llvm/pr-subscribers-mlir Author: RattataKing (RattataKing) ChangesAccording to PR #163499, minimum Python version for mlir-py is now 3.10, we no longer need patches for py<=3.9 Full diff: https://github.com/llvm/llvm-project/pull/183416.diff 2 Files Affected:
diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp
index 50eb336c9201c..32ff7a72cc298 100644
--- a/mlir/lib/Bindings/Python/IRAttributes.cpp
+++ b/mlir/lib/Bindings/Python/IRAttributes.cpp
@@ -774,12 +774,6 @@ std::unique_ptr<nb_buffer_info> PyDenseElementsAttribute::accessBuffer() {
}
void PyDenseElementsAttribute::bindDerived(ClassTy &c) {
-#if PY_VERSION_HEX < 0x03090000
- PyTypeObject *tp = reinterpret_cast<PyTypeObject *>(c.ptr());
- tp->tp_as_buffer->bf_getbuffer = PyDenseElementsAttribute::bf_getbuffer;
- tp->tp_as_buffer->bf_releasebuffer =
- PyDenseElementsAttribute::bf_releasebuffer;
-#endif
c.def("__len__", &PyDenseElementsAttribute::dunderLen)
.def_static(
"get", PyDenseElementsAttribute::getFromBuffer, nb::arg("array"),
@@ -931,14 +925,10 @@ MlirAttribute PyDenseElementsAttribute::getAttributeFromBuffer(
}
PyType_Slot PyDenseElementsAttribute::slots[] = {
-// Python 3.8 doesn't allow setting the buffer protocol slots from a type spec.
-#if PY_VERSION_HEX >= 0x03090000
{Py_bf_getbuffer,
reinterpret_cast<void *>(PyDenseElementsAttribute::bf_getbuffer)},
{Py_bf_releasebuffer,
reinterpret_cast<void *>(PyDenseElementsAttribute::bf_releasebuffer)},
-#endif
- {0, nullptr},
};
/*static*/ int PyDenseElementsAttribute::bf_getbuffer(PyObject *obj,
diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index 283f463bd3b98..88d890f36b811 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -2714,30 +2714,6 @@ namespace {
#endif // Python 3.10.0a3
-// Python 3.9.0b1
-#if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION)
-
-// bpo-40429 added PyThreadState_GetFrame()
-PyFrameObject *PyThreadState_GetFrame(PyThreadState *tstate) {
- assert(tstate != _Py_NULL && "expected tstate != _Py_NULL");
- return _Py_CAST(PyFrameObject *, Py_XNewRef(tstate->frame));
-}
-
-// bpo-40421 added PyFrame_GetBack()
-PyFrameObject *PyFrame_GetBack(PyFrameObject *frame) {
- assert(frame != _Py_NULL && "expected frame != _Py_NULL");
- return _Py_CAST(PyFrameObject *, Py_XNewRef(frame->f_back));
-}
-
-// bpo-40421 added PyFrame_GetCode()
-PyCodeObject *PyFrame_GetCode(PyFrameObject *frame) {
- assert(frame != _Py_NULL && "expected frame != _Py_NULL");
- assert(frame->f_code != _Py_NULL && "expected frame->f_code != _Py_NULL");
- return _Py_CAST(PyCodeObject *, Py_NewRef(frame->f_code));
-}
-
-#endif // Python 3.9.0b1
-
using namespace mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN;
MlirLocation tracebackToLocation(MlirContext ctx) {
|
🪟 Windows x64 Test Results
✅ The build succeeded and all tests passed. |
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
kuhar
approved these changes
Feb 26, 2026
kuhar
left a comment
Member
There was a problem hiding this comment.
Thank you! Can you also add the link to the discourse RFC to the PR description for extra context?
Let's leave this open for a few more days to get the others a chance to review.
PragmaTwice
approved these changes
Feb 26, 2026
Contributor
|
cc @hawkinsp |
Contributor
SGTM also. |
rolfmorel
approved these changes
Feb 26, 2026
kuhar
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Mar 1, 2026
According to PR llvm#163499, minimum Python version for mlir-py is now 3.10, we no longer need patches for py<=3.9. This change aligns with the Python version bump policy discussed [here](https://discourse.llvm.org/t/rfc-adopt-regularly-scheduled-python-minimum-version-bumps/88841).
RattataKing
added a commit
to iree-org/llvm-project
that referenced
this pull request
Mar 2, 2026
According to PR llvm#163499, minimum Python version for mlir-py is now 3.10, we no longer need patches for py<=3.9. This change aligns with the Python version bump policy discussed [here](https://discourse.llvm.org/t/rfc-adopt-regularly-scheduled-python-minimum-version-bumps/88841).
sujianIBM
pushed a commit
to sujianIBM/llvm-project
that referenced
this pull request
Mar 5, 2026
According to PR llvm#163499, minimum Python version for mlir-py is now 3.10, we no longer need patches for py<=3.9. This change aligns with the Python version bump policy discussed [here](https://discourse.llvm.org/t/rfc-adopt-regularly-scheduled-python-minimum-version-bumps/88841).
This was referenced Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
According to PR #163499, minimum Python version for mlir-py is now 3.10, we no longer need patches for py<=3.9.
This change aligns with the Python version bump policy discussed here.