Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Lib/test/test_bz2.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,6 @@ def testPickle(self):
with self.assertRaises(TypeError):
pickle.dumps(BZ2Decompressor(), proto)

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: 0 != 100
def testDecompressorChunksMaxsize(self):
bzd = BZ2Decompressor()
max_length = 100
Expand Down
12 changes: 6 additions & 6 deletions crates/stdlib/src/bz2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod _bz2 {
};
use alloc::fmt;
use bzip2::{Decompress, Status, write::BzEncoder};
use core::mem;
use rustpython_vm::convert::ToPyException;
use std::io::Write;

Expand Down Expand Up @@ -155,7 +156,6 @@ mod _bz2 {
}
}

// TODO: return partial results from compress() instead of returning everything in flush()
#[pyclass(with(Constructor))]
impl BZ2Compressor {
#[pymethod]
Expand All @@ -165,12 +165,12 @@ mod _bz2 {
return Err(vm.new_value_error("Compressor has been flushed"));
}

// let CompressorState { flushed, encoder } = &mut *state;
let CompressorState { encoder, .. } = &mut *state;

// TODO: handle Err
data.with_ref(|input_bytes| encoder.as_mut().unwrap().write_all(input_bytes).unwrap());
Ok(vm.ctx.new_bytes(Vec::new()))
let encoder = encoder.as_mut().unwrap();
data.with_ref(|input_bytes| encoder.write_all(input_bytes).unwrap());
// BzEncoder writes its pending output at the start of the next write.
assert_eq!(encoder.write(&[]).unwrap(), 0);
Ok(vm.ctx.new_bytes(mem::take(encoder.get_mut())))
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

#[pymethod]
Expand Down
Loading