File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import pyarrow as pa
2+ import pytest
3+
4+
5+ def test_arrow_c_stream_missing_file (ctx , tmp_path ):
6+ schema = pa .schema ([("a" , pa .int64 ())])
7+ path = tmp_path / "missing.csv"
8+ path .write_text ("a\n 1\n 2\n " )
9+ df = ctx .read_csv (path , schema = schema )
10+ capsule = df .__arrow_c_stream__ ()
11+ path .unlink ()
12+ reader = pa .RecordBatchReader ._import_from_c_capsule (capsule )
13+ with pytest .raises (Exception ): # noqa: B017
14+ reader .read_all ()
Original file line number Diff line number Diff line change @@ -410,6 +410,12 @@ impl Iterator for PartitionedDataFrameStreamReader {
410410 continue ;
411411 }
412412 Err ( e) => {
413+ #[ cfg( debug_assertions) ]
414+ {
415+ log:: error!( "PartitionedDataFrameStreamReader stream error: {e}" ) ;
416+ }
417+ // Stop iteration on error to avoid use-after-free.
418+ self . current = self . streams . len ( ) ;
413419 return Some ( Err ( ArrowError :: ExternalError ( Box :: new ( e) ) ) ) ;
414420 }
415421 }
You can’t perform that action at this time.
0 commit comments