Skip to content

bz2: fix bytes parameters #9015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 28, 2022
Merged

bz2: fix bytes parameters #9015

merged 1 commit into from
Oct 28, 2022

Conversation

JelleZijlstra
Copy link
Member

No description provided.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

def flush(self) -> bytes: ...

@final
class BZ2Decompressor:
def decompress(self, data: bytes, max_length: int = ...) -> bytes: ...
def decompress(self, data: ReadableBuffer, max_length: int = ...) -> bytes: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was a bit concerned here, as decompress uses while data: and I'm not sure if all buffers support that, but it turns out that data is overwritten with BZ2Decompressor.unused_data at the end of the first loop iteration, which appears to be bytes. So if push comes to shove, an empty bytes string is pushed into BZ2Decompressor.decompress() once (which has no effect), and then - since unused_data is now an empty bytes, it will exit the loop.

@srittau srittau merged commit cb90e9d into python:master Oct 28, 2022
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.

2 participants