diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py index b716d6016b..dfc444cbbd 100644 --- a/Lib/test/test_bz2.py +++ b/Lib/test/test_bz2.py @@ -676,8 +676,6 @@ def testCompress4G(self, size): finally: data = None - # TODO: RUSTPYTHON - @unittest.expectedFailure def testPickle(self): for proto in range(pickle.HIGHEST_PROTOCOL + 1): with self.assertRaises(TypeError): @@ -736,8 +734,6 @@ def testDecompress4G(self, size): compressed = None decompressed = None - # TODO: RUSTPYTHON - @unittest.expectedFailure def testPickle(self): for proto in range(pickle.HIGHEST_PROTOCOL + 1): with self.assertRaises(TypeError): diff --git a/stdlib/src/bz2.rs b/stdlib/src/bz2.rs index 4ae0785e47..eb334ede7b 100644 --- a/stdlib/src/bz2.rs +++ b/stdlib/src/bz2.rs @@ -103,6 +103,11 @@ mod _bz2 { self.state.lock().needs_input() } + #[pymethod(name = "__reduce__")] + fn reduce(&self, vm: &VirtualMachine) -> PyResult<()> { + Err(vm.new_type_error("cannot pickle '_bz2.BZ2Decompressor' object".to_owned())) + } + // TODO: mro()? } @@ -185,5 +190,10 @@ mod _bz2 { state.flushed = true; Ok(vm.ctx.new_bytes(out.to_vec())) } + + #[pymethod(name = "__reduce__")] + fn reduce(&self, vm: &VirtualMachine) -> PyResult<()> { + Err(vm.new_type_error("cannot pickle '_bz2.BZ2Compressor' object".to_owned())) + } } }