File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -1738,10 +1738,14 @@ def test_arrow_c_stream_capsule_released(ctx):
17381738
17391739 reader = pa .RecordBatchReader ._import_from_c_capsule (capsule )
17401740 reader .read_all ()
1741- # PyArrow may or may not clear the capsule's destructor; both behaviours are
1742- # accepted temporarily while decoupling from PyArrow
1741+ # PyArrow may or may not clear the capsule's destructor; accept both
1742+ # behaviours temporarily while decoupling from PyArrow. Record the
1743+ # destructor value but don't assert a specific value here so the test
1744+ # works against pyarrow builds that clear the destructor and those that
1745+ # don't. The key checks are that import succeeds and cleanup does not
1746+ # lead to a double free (ensured by deleting the reader and forcing
1747+ # garbage collection below).
17431748 _ = get_destructor (capsule )
1744- # Pointer remains retrievable
17451749 assert get_ptr (capsule , b"arrow_array_stream" )
17461750 pyerr_clear ()
17471751
Original file line number Diff line number Diff line change @@ -988,6 +988,9 @@ impl PyDataFrame {
988988 let reader: Box < dyn RecordBatchReader + Send > = Box :: new ( reader) ;
989989
990990 let stream = FFI_ArrowArrayStream :: new ( reader) ;
991+ // This custom destructor is defensive to avoid a double free. It is
992+ // a temporary workaround until DataFusion's Python bindings decouple
993+ // from PyArrow.
991994 // The returned capsule allows zero-copy hand-off to PyArrow. When
992995 // PyArrow imports the capsule it assumes ownership of the stream and
993996 // nulls out the capsule's internal pointer so the destructor does not
You can’t perform that action at this time.
0 commit comments