Skip to content

Commit 94f9129

Browse files
committed
chore(dissect.cstruct): Make Unblob compatible with version 4.0
We cannot upgrade our requirement to 4.0, as it has no Python 3.8 support. The second best thing we can do is to relax the dependency specification and make our logging code compatible with both versions. This is the only place we depend on runtime types. Fixes: #888
1 parent eb8b1b5 commit 94f9129

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ packages = [
1111
[tool.poetry.dependencies]
1212
python = "^3.8"
1313
click = "^8.1.7"
14-
"dissect.cstruct" = "^2.0"
14+
"dissect.cstruct" = ">=2.0,<5.0"
1515
attrs = ">=23.1.0"
1616
structlog = ">=24.1.0"
1717
arpy = "^2.3.0"

unblob/logging.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
from typing import Any
88

99
import structlog
10-
from dissect.cstruct import Instance, dumpstruct
10+
from dissect.cstruct import dumpstruct
11+
12+
try:
13+
# dissect.cstruct >= 4.0
14+
from dissect.cstruct import Structure
15+
except ImportError:
16+
# dissect.cstruct == 2.0
17+
from dissect.cstruct import Instance as Structure
1118

1219

1320
def format_hex(value: int):
@@ -42,7 +49,7 @@ def _format_message(value: Any, extract_root: Path) -> Any:
4249
new_value = value
4350
return new_value.as_posix().encode("utf-8", errors="surrogateescape")
4451

45-
if isinstance(value, Instance):
52+
if isinstance(value, Structure):
4653
return dumpstruct(value, output="string")
4754

4855
if isinstance(value, int):

0 commit comments

Comments
 (0)