Skip to content

Commit 473ceec

Browse files
committed
rust: upgrade PyO3 0.22 -> 0.23
I implemented `Sync` without actually verifying the underlying types are thread safe. I could have introduced major bugs in free-threaded builds! We don't yet support free-threaded builds and we can't not implement `Sync`. So I'm fine deferring the hard work of doing this audit. There were some compiler errors related to type coercion. So those were fixed too. Not fixed are a ton of new warnings we get with the upgrade.
1 parent dea3b87 commit 473ceec

18 files changed

Lines changed: 62 additions & 20 deletions

Cargo.lock

Lines changed: 10 additions & 10 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.22.6"
29+
version = "0.23.5"
3030
features = ["extension-module"]

docs/news.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Changes
5959
and we didn't run tests on this platform.
6060
* We now `collections.abs.Buffer` on Python 3.12+ instead of `typing.ByteString`,
6161
as `typing.ByteString` was deprecated and later removed. (#238, #262)
62-
* PyO3 Rust crate upgraded from 0.21 to 0.22. (#257)
62+
* PyO3 Rust crate upgraded from 0.21 to 0.22 (#257) and later to 0.23.
6363

6464
Backwards Compatibility Notes
6565
-----------------------------

rust-ext/src/buffers.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ pub struct ZstdBufferSegment {
3434
len: usize,
3535
}
3636

37+
unsafe impl Sync for ZstdBufferSegment {}
38+
3739
impl ZstdBufferSegment {
3840
pub fn as_slice(&self) -> &[u8] {
3941
unsafe {
@@ -90,6 +92,8 @@ pub struct ZstdBufferSegments {
9092
parent: PyObject,
9193
}
9294

95+
unsafe impl Sync for ZstdBufferSegments {}
96+
9397
#[pymethods]
9498
impl ZstdBufferSegments {
9599
// PyBufferProtocol.
@@ -126,6 +130,8 @@ pub struct ZstdBufferWithSegments {
126130
pub(crate) segments: Vec<BufferSegment>,
127131
}
128132

133+
unsafe impl Sync for ZstdBufferWithSegments {}
134+
129135
impl ZstdBufferWithSegments {
130136
fn as_slice(&self) -> &[u8] {
131137
unsafe {
@@ -269,6 +275,8 @@ pub struct ZstdBufferWithSegmentsCollection {
269275
first_elements: Vec<usize>,
270276
}
271277

278+
unsafe impl Sync for ZstdBufferWithSegmentsCollection {}
279+
272280
#[pymethods]
273281
impl ZstdBufferWithSegmentsCollection {
274282
// PySequenceProtocol.

rust-ext/src/compression_chunker.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pub struct ZstdCompressionChunker {
2323
partial_buffer: Option<Vec<u8>>,
2424
}
2525

26+
unsafe impl Sync for ZstdCompressionChunker {}
27+
2628
impl ZstdCompressionChunker {
2729
pub fn new(cctx: Arc<CCtx<'static>>, chunk_size: usize) -> PyResult<Self> {
2830
Ok(Self {
@@ -186,6 +188,8 @@ struct ZstdCompressionChunkerIterator {
186188
finished: bool,
187189
}
188190

191+
unsafe impl Sync for ZstdCompressionChunkerIterator {}
192+
189193
#[pymethods]
190194
impl ZstdCompressionChunkerIterator {
191195
// PyIterProtocol.

rust-ext/src/compression_dict.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ pub struct ZstdCompressionDict {
4444
ddict: Option<DDict<'static>>,
4545
}
4646

47+
unsafe impl Sync for ZstdCompressionDict {}
48+
4749
impl ZstdCompressionDict {
4850
pub(crate) fn load_into_cctx(&self, cctx: &CCtx) -> PyResult<()> {
4951
if let Some(cdict) = &self.cdict {

rust-ext/src/compression_parameters.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ pub struct ZstdCompressionParameters {
207207
pub(crate) params: *mut zstd_sys::ZSTD_CCtx_params,
208208
}
209209

210+
unsafe impl Sync for ZstdCompressionParameters {}
211+
210212
impl Drop for ZstdCompressionParameters {
211213
fn drop(&mut self) {
212214
unsafe {

rust-ext/src/compression_reader.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ pub struct ZstdCompressionReader {
3030
finished_output: bool,
3131
}
3232

33+
unsafe impl Sync for ZstdCompressionReader {}
34+
3335
impl ZstdCompressionReader {
3436
pub fn new(
3537
py: Python,

rust-ext/src/compression_writer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ pub struct ZstdCompressionWriter {
3131
dest_buffer: Vec<u8>,
3232
}
3333

34+
unsafe impl Sync for ZstdCompressionWriter {}
35+
3436
impl ZstdCompressionWriter {
3537
pub fn new(
3638
py: Python,

rust-ext/src/compressionobj.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub struct ZstdCompressionObj {
2020
finished: bool,
2121
}
2222

23+
unsafe impl Sync for ZstdCompressionObj {}
24+
2325
impl ZstdCompressionObj {
2426
pub fn new(cctx: Arc<CCtx<'static>>) -> PyResult<Self> {
2527
Ok(ZstdCompressionObj {

0 commit comments

Comments
 (0)