Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Wrap/PyArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions test/Wrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@
end
end

@testitem "PyArray buffer with suboffsets is rejected" 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

@testitem "PyDict" begin
x = pydict(["foo" => 12])
y = PyDict(x)
Expand Down
Loading