Skip to content
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

Apply bug workaround in plocate plugin to all PyPy versions #546

Merged
merged 2 commits into from
Feb 19, 2024
Merged
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
5 changes: 2 additions & 3 deletions dissect/target/plugins/os/unix/locate/plocate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import platform
import sys
from io import BytesIO
from typing import BinaryIO, Iterable

Expand Down Expand Up @@ -114,12 +113,12 @@ def __init__(self, fh: BinaryIO):
self.buf = RangeStream(self.fh, self.fh.tell(), self.compressed_length_bytes)

def __iter__(self) -> Iterable[PLocateFile]:
# NOTE: This is a workaround for a PyPy 3.9 bug
# NOTE: This is a workaround for a PyPy bug
# We don't know what breaks, but PyPy + zstandard = unhappy times
# You just get random garbage data back instead of the decompressed data
# This weird dance of using a decompressobj and unused data is the only way that seems to work
# It's more expensive on memory, but at least it doesn't break
if platform.python_implementation() == "PyPy" and sys.version_info < (3, 10):
if platform.python_implementation() == "PyPy":
obj = self.ctx.decompressobj()
buf = self.buf.read()

Expand Down
Loading