()
| 505 | |
| 506 | @needs_cffi |
| 507 | def test_export_import_exception_reader(): |
| 508 | # See: https://github.com/apache/arrow/issues/37164 |
| 509 | c_stream = ffi.new("struct ArrowArrayStream*") |
| 510 | ptr_stream = int(ffi.cast("uintptr_t", c_stream)) |
| 511 | |
| 512 | gc.collect() # Make sure no Arrow data dangles in a ref cycle |
| 513 | old_allocated = pa.total_allocated_bytes() |
| 514 | |
| 515 | def gen(): |
| 516 | if True: |
| 517 | try: |
| 518 | raise ValueError('foo') |
| 519 | except ValueError as e: |
| 520 | raise NotImplementedError('bar') from e |
| 521 | else: |
| 522 | yield from make_batches() |
| 523 | |
| 524 | original = pa.RecordBatchReader.from_batches(make_schema(), gen()) |
| 525 | original._export_to_c(ptr_stream) |
| 526 | |
| 527 | reader = pa.RecordBatchReader._import_from_c(ptr_stream) |
| 528 | with pytest.raises(NotImplementedError) as exc_info: |
| 529 | reader.read_next_batch() |
| 530 | |
| 531 | # inner *and* outer exception should be present |
| 532 | assert 'ValueError: foo' in str(exc_info.value) |
| 533 | assert 'NotImplementedError: bar' in str(exc_info.value) |
| 534 | # Stacktrace containing line of the raise statement |
| 535 | assert 'raise ValueError(\'foo\')' in str(exc_info.value) |
| 536 | |
| 537 | assert pa.total_allocated_bytes() == old_allocated |
| 538 | |
| 539 | |
| 540 | @needs_cffi |
nothing calls this directly
no test coverage detected