diff --git a/CHANGELOG.md b/CHANGELOG.md index f1366eb2..0c414625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Unreleased +* Bug fixes. + ## 0.9.34 (2026-05-18) * Bug fixes. diff --git a/src/Wrap/PyArray.jl b/src/Wrap/PyArray.jl index 7b1dc8d3..dc11c085 100644 --- a/src/Wrap/PyArray.jl +++ b/src/Wrap/PyArray.jl @@ -531,6 +531,8 @@ end function PyArraySource_Buffer(x::Py) memview = pybuiltins.memoryview(x) buf = C.UnsafePtr(C.PyMemoryView_GET_BUFFER(memview)) + buf.suboffsets[] == C_NULL || + error("PyArray does not support buffers with non-trivial suboffsets (PIL-style indirect layout)") PyArraySource_Buffer(x, memview, buf) end diff --git a/test/Wrap.jl b/test/Wrap.jl index c42d45ab..09d6ece7 100644 --- a/test/Wrap.jl +++ b/test/Wrap.jl @@ -89,6 +89,16 @@ @test strides(y) == strides(y2) @test y == y2 end + @testset "reject suboffsets (#775)" begin + tb = pyimport("_testbuffer") + nd = tb.ndarray( + pylist([1, 2, 3, 4, 5, 6]), + shape = pylist([2, 3]), + format = "i", + flags = tb.ND_PIL | tb.ND_WRITABLE, + ) + @test_throws Exception PyArray(nd; array = false, buffer = true) + end end @testitem "PyDict" begin