emilk opened a new pull request, #10730:
URL: https://github.com/apache/arrow-rs/pull/10730

   # Which issue does this PR close?
   
   * Part of https://github.com/apache/arrow-rs/issues/10553
   * Follow-up to https://github.com/apache/arrow-rs/pull/10656
   
   # Rationale for this change
   
   A `try_` function that returns a `Result` but still panics is the worst of 
both worlds: the caller writes error handling and gets a panic anyway. After 
#10656 documented `# Panics` everywhere, these are easy to find.
   
   # What changes are included in this PR?
   
   * `FFI_ArrowSchema::try_new`: an interior nul byte in `format` was an 
`unwrap`. Now returns `ArrowError::CDataInterface`. The format is converted 
before the children are leaked, so the error path no longer leaks memory.
   * `MutableArrayData::try_extend`: validates the source array index and the 
`start..end` range. `end < start` used to underflow.
   * `MutableArrayData::try_extend_nulls`: returns an error instead of 
panicking when the builder has no null buffer.
   * `VariantArray::try_value`: returns an error for an out of bounds index, 
and for a row with conflicting `value` and `typed_value`.
   * `try_binary`: `NullBuffer::union` returns `None` when neither input has 
logical nulls, which is possible even when `null_count() > 0`. Falls back to 
the no-nulls path instead of unwrapping.
   
   `MutableBuffer::try_from_trusted_len_iter` still panics on a bad 
`size_hint`: that is part of its `unsafe` contract, and the docs now say so.
   
   # Are these changes tested?
   
   Yes, new tests for each error path. One existing test 
(`test_extend_nulls_panic`) asserted the old panic and now asserts the error.
   
   # Are there any user-facing changes?
   
   Panics turn into errors, so code that relied on the panic (only via 
`catch_unwind`) would notice. `MutableArrayData::extend`/`extend_nulls` still 
panic as before.


-- 
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]

Reply via email to