Skip to content

Commit e6823a6

Browse files
committed
Fix pyo3 0.25 API incompatibilities
1 parent 7748850 commit e6823a6

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust-ext/src/buffers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use {
1111
exceptions::{PyIndexError, PyTypeError, PyValueError},
1212
ffi::Py_buffer,
1313
prelude::*,
14-
types::{PyBytes, PyTuple},
14+
types::{PyBytes, PyTuple}, IntoPyObjectExt,
1515
},
1616
};
1717

@@ -242,7 +242,7 @@ impl ZstdBufferWithSegments {
242242
}
243243

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

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

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

rust-ext/src/compression_chunker.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use {
1010
stream::{make_in_buffer_source, InBufferSource},
1111
zstd_safe::CCtx,
1212
},
13-
pyo3::{prelude::*, types::PyBytes},
13+
pyo3::{prelude::*, types::PyBytes, IntoPyObjectExt},
1414
std::sync::Arc,
1515
};
1616

@@ -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(py)));
228+
return Ok(Some(chunk.into_py_any(py).unwrap()));
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(py)))
281+
Ok(Some(chunk.into_py_any(py).unwrap()))
282282
}
283283
}

rust-ext/src/compression_writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use {
1010
buffer::PyBuffer,
1111
exceptions::{PyNotImplementedError, PyOSError, PyValueError},
1212
prelude::*,
13-
types::PyBytes,
13+
types::PyBytes, IntoPyObjectExt,
1414
},
1515
std::sync::Arc,
1616
};
@@ -48,7 +48,7 @@ impl ZstdCompressionWriter {
4848

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

rust-ext/src/compressor_iterator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use {
1010
stream::{make_in_buffer_source, InBufferSource},
1111
zstd_safe::CCtx,
1212
},
13-
pyo3::{prelude::*, types::PyBytes},
13+
pyo3::{prelude::*, types::PyBytes, IntoPyObjectExt},
1414
std::sync::Arc,
1515
};
1616

@@ -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(py)));
63+
return Ok(Some(chunk.into_py_any(py).unwrap()));
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(py)));
97+
return Ok(Some(chunk.into_py_any(py).unwrap()));
9898
}
9999

100100
Ok(None)

rust-ext/src/decompression_writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use {
1010
buffer::PyBuffer,
1111
exceptions::{PyOSError, PyValueError},
1212
prelude::*,
13-
types::PyBytes,
13+
types::PyBytes, IntoPyObjectExt,
1414
},
1515
std::sync::Arc,
1616
};
@@ -40,7 +40,7 @@ impl ZstdDecompressionWriter {
4040
) -> PyResult<Self> {
4141
Ok(Self {
4242
dctx,
43-
writer: writer.into_py(py),
43+
writer: writer.into_py_any(py).unwrap(),
4444
write_size,
4545
write_return_read,
4646
closefd,

rust-ext/src/decompressor_iterator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use {
1010
stream::{make_in_buffer_source, InBufferSource},
1111
zstd_safe::DCtx,
1212
},
13-
pyo3::{exceptions::PyValueError, prelude::*, types::PyBytes},
13+
pyo3::{exceptions::PyValueError, prelude::*, types::PyBytes, IntoPyObjectExt},
1414
std::{cmp::min, sync::Arc},
1515
};
1616

@@ -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(py)));
63+
return Ok(Some(chunk.into_py_any(py).unwrap()));
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(py)))
74+
Ok(Some(chunk.into_py_any(py).unwrap()))
7575
} else {
7676
Ok(None)
7777
}

rust-ext/src/stream.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// of the BSD license. See the LICENSE file for details.
66

77
use {
8-
pyo3::{buffer::PyBuffer, exceptions::PyValueError, prelude::*},
8+
pyo3::{buffer::PyBuffer, exceptions::PyValueError, prelude::*, IntoPyObjectExt},
99
zstd_sys::ZSTD_inBuffer,
1010
};
1111

@@ -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(py),
142+
source: source.into_py_any(py).unwrap(),
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(py),
156+
source: source.into_py_any(py).unwrap(),
157157
buffer,
158158
offset: 0,
159159
}))

0 commit comments

Comments
 (0)