AlenkaF commented on code in PR #51309:
URL: https://github.com/apache/arrow/pull/51309#discussion_r4005944140
##########
python/pyarrow/tests/test_dlpack.py:
##########
@@ -270,10 +270,11 @@ def immutable_tensor():
@pytest.mark.parametrize('max_version', [None, (0, 8)])
def test_dlpack_legacy_capsule_immutable_tensor(max_version):
tensor = immutable_tensor()
- with pytest.raises(NotImplementedError,
- match="Legacy DLPack support is not implemented "
- "for immutable tensors"):
- tensor.__dlpack__(max_version=max_version)
+ with pytest.warns(DeprecationWarning, match="unversioned DLPack capsule"):
+ with pytest.raises(NotImplementedError,
+ match="Legacy DLPack support is not implemented "
+ "for immutable tensors"):
+ tensor.__dlpack__(max_version=max_version)
Review Comment:
Ha, this is coming from our code, yes.
`DeprecationWarning` is triggered in Cython, `NotImplementedError` is
triggered in C++. I think we only need to change the order here:
https://github.com/apache/arrow/blob/9ae25f1a9213ada1bcea2398e9d40d45eece8146/python/pyarrow/array.pxi#L2375-L2379
where the warning is triggered only after `legacy_tensor` is successfully
created. Same in tensor.pxi.
I can create a separate PR tomorrow, if this change is out of scope for this
issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]