refactor(python): read pyc and PYZ marshal values through one shared reader (#10806)

* refactor(python): read pyc and PYZ marshal values through one shared reader

* refactor(python): read pyc 64-bit values and header fields through shared readers (#10834)
This commit is contained in:
morluto authored and GitHub committed 2026-11-15 16:50:58 +08:00
1 parent 8443930bd3
commit 479abaf3b2
5 files changed
+716 -561

No files matched your search

+22
View File
@@ -135,6 +135,28 @@ it("rejects truncated marshal without partial success", () => {
);
});
it.each([
{ type: 0x67, message: "Marshal stream ended inside a float." },
{ type: 0x49, message: "Marshal stream ended inside a 64-bit integer." },
])(
"reports a truncated 8-byte marshal value 0x$type as a malformed truncation",
({ type, message }) => {
const bytes = Buffer.concat([
pythonPycHeader(3571),
Buffer.from([type, 0, 0, 0, 0]),
]);
expect(() => parse(bytes)).toThrow(
expect.objectContaining({
message,
failure: expect.objectContaining({
kind: "malformed",
field: "truncated",
}),
}),
);
},
);
it.each([
{ magic: 3571, layout: "py311", version: "3.13" },
{ magic: 3627, layout: "py311", version: "3.14" },