Skip to content

Commit 058f437

Browse files
committed
Replace into_py_any(py).unwrap() with into_any_py(py)?
1 parent e6823a6 commit 058f437

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

rust-ext/src/buffers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl ZstdBufferWithSegments {
242242
}
243243

244244
Ok(Self {
245-
source: data.into_py_any(py).unwrap(),
245+
source: data.into_py_any(py)?,
246246
buffer: data_buffer,
247247
segments,
248248
})
@@ -344,7 +344,7 @@ impl ZstdBufferWithSegmentsCollection {
344344

345345
offset += segment.segments.len();
346346

347-
buffers.push(item.into_py_any(py).unwrap());
347+
buffers.push(item.into_py_any(py)?);
348348
first_elements.push(offset);
349349
}
350350

rust-ext/src/compression_chunker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl ZstdCompressionChunkerIterator {
225225
let chunk = PyBytes::new(py, &slf.dest_buffer);
226226
slf.dest_buffer.clear();
227227

228-
return Ok(Some(chunk.into_py_any(py).unwrap()));
228+
return Ok(Some(chunk.into_py_any(py)?));
229229
}
230230

231231
// Else continue to compress available input data.
@@ -278,6 +278,6 @@ impl ZstdCompressionChunkerIterator {
278278
let chunk = PyBytes::new(py, &slf.dest_buffer);
279279
slf.dest_buffer.clear();
280280

281-
Ok(Some(chunk.into_py_any(py).unwrap()))
281+
Ok(Some(chunk.into_py_any(py)?))
282282
}
283283
}

rust-ext/src/compression_writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl ZstdCompressionWriter {
4848

4949
Ok(Self {
5050
cctx,
51-
writer: writer.into_py_any(py).unwrap(),
51+
writer: writer.into_py_any(py)?,
5252
write_return_read,
5353
closefd,
5454
entered: false,

rust-ext/src/compressor_iterator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl ZstdCompressorIterator {
6060
// TODO avoid buffer copy
6161
let chunk = PyBytes::new(py, &dest_buffer);
6262

63-
return Ok(Some(chunk.into_py_any(py).unwrap()));
63+
return Ok(Some(chunk.into_py_any(py)?));
6464
}
6565

6666
// Else read another chunk in hopes of producing output data.
@@ -94,7 +94,7 @@ impl ZstdCompressorIterator {
9494
// TODO avoid buffer copy.
9595
let chunk = PyBytes::new(py, &dest_buffer);
9696

97-
return Ok(Some(chunk.into_py_any(py).unwrap()));
97+
return Ok(Some(chunk.into_py_any(py)?));
9898
}
9999

100100
Ok(None)

rust-ext/src/decompression_writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl ZstdDecompressionWriter {
4040
) -> PyResult<Self> {
4141
Ok(Self {
4242
dctx,
43-
writer: writer.into_py_any(py).unwrap(),
43+
writer: writer.into_py_any(py)?,
4444
write_size,
4545
write_return_read,
4646
closefd,

rust-ext/src/decompressor_iterator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl ZstdDecompressorIterator {
6060
if !dest_buffer.is_empty() {
6161
// TODO avoid buffer copy.
6262
let chunk = PyBytes::new(py, &dest_buffer);
63-
return Ok(Some(chunk.into_py_any(py).unwrap()));
63+
return Ok(Some(chunk.into_py_any(py)?));
6464
}
6565

6666
// Repeat loop to collect more input data.
@@ -71,7 +71,7 @@ impl ZstdDecompressorIterator {
7171
if !dest_buffer.is_empty() {
7272
// TODO avoid buffer copy.
7373
let chunk = PyBytes::new(py, &dest_buffer);
74-
Ok(Some(chunk.into_py_any(py).unwrap()))
74+
Ok(Some(chunk.into_py_any(py)?))
7575
} else {
7676
Ok(None)
7777
}

rust-ext/src/stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub(crate) fn make_in_buffer_source(
139139
) -> PyResult<Box<dyn InBufferSource + Send>> {
140140
if source.hasattr("read")? {
141141
Ok(Box::new(ReadSource {
142-
source: source.into_py_any(py).unwrap(),
142+
source: source.into_py_any(py)?,
143143
buffer: None,
144144
read_size,
145145
finished: false,
@@ -153,7 +153,7 @@ pub(crate) fn make_in_buffer_source(
153153
})?;
154154

155155
Ok(Box::new(BufferSource {
156-
source: source.into_py_any(py).unwrap(),
156+
source: source.into_py_any(py)?,
157157
buffer,
158158
offset: 0,
159159
}))

0 commit comments

Comments
 (0)