Skip to content

Commit ac72ed0

Browse files
ngoldbaumindygreg
authored andcommitted
rust: update to PyO3 0.22
Closes #257.
1 parent bb70cf8 commit ac72ed0

File tree

10 files changed

+32
-153
lines changed

10 files changed

+32
-153
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,15 @@ jobs:
8989
run: |
9090
python -m pip install --require-hashes -r ci/requirements.txt
9191
92-
# TODO enable once PyO3 supports 3.13.
9392
- name: Build (Rust)
94-
if: matrix.arch == 'x64' && matrix.py != '3.13'
93+
if: matrix.arch == 'x64'
9594
env:
9695
PIP_CONSTRAINT: 'ci/constraints.txt'
9796
run: |
9897
python -m pip install --config-settings='--build-option=--rust-backend' -e .
9998
10099
- name: Build (No Rust)
101-
if: matrix.arch != 'x64' || matrix.py == '3.13'
100+
if: matrix.arch != 'x64'
102101
run: |
103102
python -m pip install -e .
104103

Cargo.lock

Lines changed: 14 additions & 138 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ version = "2.0.10+zstd.1.5.6"
2626
features = ["experimental", "legacy", "zstdmt"]
2727

2828
[dependencies.pyo3]
29-
version = "0.21.2"
29+
version = "0.22.6"
3030
features = ["extension-module"]

docs/news.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Changes
6262
we never ran tests for the Windows ARM platform.
6363
* We now `collections.abs.Buffer` on Python 3.12+ instead of `typing.ByteString`,
6464
as `typing.ByteString` was deprecated and later removed. (#238, #262)
65+
* PyO3 Rust crate upgraded from 0.21 to 0.22. (#257)
6566

6667
Backwards Compatibility Notes
6768
-----------------------------

rust-ext/src/compression_chunker.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl ZstdCompressionChunker {
8585

8686
let source = make_in_buffer_source(py, data, zstd_safe::CCtx::in_size())?;
8787

88-
let it = Py::new(
88+
let it = Bound::new(
8989
py,
9090
ZstdCompressionChunkerIterator {
9191
cctx: self.cctx.clone(),
@@ -96,9 +96,9 @@ impl ZstdCompressionChunker {
9696
},
9797
)?;
9898

99-
self.iterator = Some(it.clone());
99+
self.iterator = Some(it.clone().unbind());
100100

101-
Ok(it)
101+
Ok(it.unbind())
102102
}
103103

104104
fn flush<'p>(&mut self, py: Python<'p>) -> PyResult<Py<ZstdCompressionChunkerIterator>> {
@@ -119,7 +119,7 @@ impl ZstdCompressionChunker {
119119
let source =
120120
make_in_buffer_source(py, &PyBytes::new_bound(py, &[]), zstd_safe::CCtx::in_size())?;
121121

122-
let it = Py::new(
122+
let it = Bound::new(
123123
py,
124124
ZstdCompressionChunkerIterator {
125125
cctx: self.cctx.clone(),
@@ -130,9 +130,9 @@ impl ZstdCompressionChunker {
130130
},
131131
)?;
132132

133-
self.iterator = Some(it.clone());
133+
self.iterator = Some(it.clone().unbind());
134134

135-
Ok(it)
135+
Ok(it.unbind())
136136
}
137137

138138
fn finish<'p>(&mut self, py: Python<'p>) -> PyResult<Py<ZstdCompressionChunkerIterator>> {
@@ -153,7 +153,7 @@ impl ZstdCompressionChunker {
153153
let source =
154154
make_in_buffer_source(py, &PyBytes::new_bound(py, &[]), zstd_safe::CCtx::in_size())?;
155155

156-
let it = Py::new(
156+
let it = Bound::new(
157157
py,
158158
ZstdCompressionChunkerIterator {
159159
cctx: self.cctx.clone(),
@@ -164,9 +164,9 @@ impl ZstdCompressionChunker {
164164
},
165165
)?;
166166

167-
self.iterator = Some(it.clone());
167+
self.iterator = Some(it.clone().unbind());
168168

169-
Ok(it)
169+
Ok(it.unbind())
170170
}
171171
}
172172

rust-ext/src/compression_writer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ impl ZstdCompressionWriter {
184184
false
185185
}
186186

187+
#[pyo3(signature = (size=None))]
187188
#[allow(unused_variables)]
188189
fn truncate(&self, py: Python, size: Option<&Bound<'_, PyAny>>) -> PyResult<()> {
189190
let io = py.import_bound("io")?;

rust-ext/src/compressionobj.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl ZstdCompressionObj {
6666
Ok(PyBytes::new_bound(py, &compressed))
6767
}
6868

69+
#[pyo3(signature = (flush_mode=None))]
6970
fn flush<'p>(
7071
&mut self,
7172
py: Python<'p>,

rust-ext/src/compressor_multi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub fn multi_compress_to_buffer(
6868
total_source_size += slice.len();
6969
}
7070
}
71-
} else if let Ok(list) = data.extract::<&PyList>() {
71+
} else if let Ok(list) = data.extract::<Bound<'_, PyList>>() {
7272
sources.reserve_exact(list.len());
7373

7474
for (i, item) in list.iter().enumerate() {

rust-ext/src/decompressionobj.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ impl ZstdDecompressionObj {
102102
empty.call_method1("join", (chunks,))
103103
}
104104

105+
#[pyo3(signature = (length=None))]
105106
#[allow(unused_variables)]
106107
fn flush<'p>(&self, py: Python<'p>, length: Option<usize>) -> PyResult<Bound<'p, PyBytes>> {
107108
Ok(PyBytes::new_bound(py, &[]))

rust-ext/src/decompressor_multi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn multi_decompress_to_buffer(
9999
offset += 1;
100100
}
101101
}
102-
} else if let Ok(list) = frames.extract::<&PyList>() {
102+
} else if let Ok(list) = frames.extract::<Bound<'_, PyList>>() {
103103
if decompressed_sizes.is_some() && frame_sizes.len() != list.len() {
104104
return Err(PyValueError::new_err(format!(
105105
"decompressed_sizes size mismatch; expected {}; got {}",

0 commit comments

Comments
 (0)