mirror of
https://github.com/morluto/rea.git
synced 2026-10-29 10:55:57 +00:00
fix(python): preserve historical signed code fields
Keep signed co_stacksize and co_flags for historical magic entries whose constructors accepted them. Preserve magic 3410 with a constructor-revision limitation; reject negative values from 3411 onward. Fixes #6487
This commit is contained in:
1 parent
667402846c
commit
c6ab965062
7 files changed
+253
-79
No files matched your search
@@ -1520,9 +1520,12 @@ it("rejects code CPython treats as corrupt instead of complete coverage", () =>
|
||||
expect(() => parse(file("py311", 3531, { flags: 0x80000000 }))).toThrow(
|
||||
/co_flags is negative/,
|
||||
);
|
||||
expect(() => parse(file("py37", 3401, { flags: 0x80000000 }))).toThrow(
|
||||
expect(() => parse(file("py38", 3411, { flags: 0x80000000 }))).toThrow(
|
||||
/co_flags is negative/,
|
||||
);
|
||||
expect(() => parse(file("py38", 3411, { stacksize: 0xffffffff }))).toThrow(
|
||||
/co_stacksize is negative/,
|
||||
);
|
||||
|
||||
const valid = parse(
|
||||
file("py311", 3531, {
|
||||
@@ -1544,6 +1547,25 @@ it("rejects code CPython treats as corrupt instead of complete coverage", () =>
|
||||
const negativePy37Flags = parse(file("py37", 3394, { flags: 0x80000000 }));
|
||||
expect(root(negativePy37Flags).flags).toBe(-0x80000000);
|
||||
expect(pythonPycSchema.safeParse(negativePy37Flags).success).toBe(true);
|
||||
const negativePy37Stacksize = parse(
|
||||
file("py37", 3394, { stacksize: 0xffffffff }),
|
||||
);
|
||||
expect(root(negativePy37Stacksize).stacksize).toBe(-1);
|
||||
expect(pythonPycSchema.safeParse(negativePy37Stacksize).success).toBe(true);
|
||||
const negativePy38AlphaFlags = parse(
|
||||
file("py37", 3401, { flags: 0x80000000 }),
|
||||
);
|
||||
expect(root(negativePy38AlphaFlags).flags).toBe(-0x80000000);
|
||||
const ambiguousPy38Fields = parse(
|
||||
file("py38", 3410, { stacksize: 0xffffffff, flags: 0x80000000 }),
|
||||
);
|
||||
expect(root(ambiguousPy38Fields)).toMatchObject({
|
||||
stacksize: -1,
|
||||
flags: -0x80000000,
|
||||
});
|
||||
expect(ambiguousPy38Fields.limitations).toEqual(
|
||||
expect.arrayContaining([expect.stringContaining("Magic 3410 is shared")]),
|
||||
);
|
||||
const py37 = parse(
|
||||
file("py37", 3394, {
|
||||
argcount: 1,
|
||||
|
||||
Reference in new issue
Block a user