FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Switch to `libbz2-rs-sys` and finish bz2 impl by coolreader18 · Pull Request #5709 · RustPython/RustPython · GitHub

Switch to libbz2-rs-sys and finish bz2 impl - #5709

Merged
coolreader18 merged 3 commits into
RustPython:mainfrom
coolreader18:bz2
Apr 20, 2025
Merged

Switch to libbz2-rs-sys and finish bz2 impl#5709
coolreader18 merged 3 commits into
RustPython:mainfrom
coolreader18:bz2

Conversation

coolreader18 commented Apr 17, 2025
edited
Loading

Copy link
Copy Markdown
Member

I realized that libbz2-rs-sys exists, by the same folks who make libz-rs-sys - it's a Rust reimplementation of libbz2. This means we can do that same thing as in #5562, and avoid having to cross-compile C. I then realized after I removed the feature flag that we weren't actually running bz2 regrtests in CI, because we weren't passing it as a feature to cargo build, and so something like half of the tests in test_bz2.py were failing. So, I more or less finished up the impl, by making some code in zlib.rs generic over the specific Decompress struct.

Copy link
Copy Markdown
Contributor

See also #5605

Copy link
Copy Markdown
Contributor

This one is better than mine ... test_shutil is the only fail (due to 1 new exposed test) and there aren't too many expected failures comparatively. I'll close mine after this is merged.

Copy link
Copy Markdown
Member

please check #5605 and rebase on it or pick some idea if possible

Copy link
Copy Markdown
Member Author

Oh, shoot, sorry - I didn't see that that PR was open.

Comment thread stdlib/src/bz2.rs
object::{PyPayload, PyResult},
types::Constructor,
};
use crate::zlib::{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Since there is at-least 1 other decompression module that uses the same format (_lzma). I think this should be moved someplace common.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I agree - I was planning on doing that in a followup, to reduce the amount of code movement in this pr.

Comment thread Lib/test/test_bz2.py
self.assertEqual(f.read(), "foobar")

# TODO: RUSTPYTHON
@unittest.expectedFailure

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@coolreader18 @arihant2math what cause this regression? could this be fixed in future?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

A flag probably needs to be added to the decompressor state. I believe the issue is the wt and rt formats. Although I'm not to sure, I suppose looking at the cpython source might help.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The reason this needed to be flagged now is because the whole test file wasn't running at all before - bz2 was not included in the --features=stdlib,threading,... flag in CI, so the module wasn't even getting compiled or tested at all.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Oh, didn't noticed that. Thanks!

Copy link
Copy Markdown
Contributor

I checkout out of this pr for #5717 so try not to change the trait too much 😄 .

Comment thread stdlib/src/zlib.rs
}
impl<'a> Chunker<'a> {
fn new(data: &'a [u8]) -> Self {
pub(crate) fn new(data: &'a [u8]) -> Self {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
pub(crate) fn new(data: &'a [u8]) -> Self {
pub fn new(data: &'a [u8]) -> Self {

When the struct is pub(crate), only pub here is automatically pub(crate)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

True, I think I'll change that in the follow-up.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL