mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
feat(python): decode CPython 3.14 and 3.15 pyc code objects
Decode marshal slice constants from magic 3608 onward and pin the 3.11 code layout and inline-cache tables for the 3.14 and 3.15 magics. Refs #8206
This commit is contained in:
1 parent
5451d3cb2d
commit
1d08253ff2
14 files changed
+471
-69
No files matched your search
@@ -8,6 +8,8 @@ import {
|
||||
export const PYTHON_PYC_HEADER_BYTES = 16;
|
||||
export const PYTHON_PYC_HASH_BASED = 0x1;
|
||||
export const PYTHON_PYC_CHECK_SOURCE = 0x2;
|
||||
/** CPython 3.14a1 magic 3608 added TYPE_SLICE to marshal (gh-125063). */
|
||||
export const PYTHON_PYC_SLICE_MAGIC = 3608;
|
||||
|
||||
const uint = z.number().int().min(0).max(0xffffffff);
|
||||
const index = z.number().int().nonnegative();
|
||||
@@ -59,6 +61,13 @@ export const PYTHON_PYC_MARSHAL_PROFILES: ReadonlyMap<
|
||||
...consecutiveProfiles(3494, 3495, "py311"),
|
||||
...consecutiveProfiles(3500, 3531, "py311"),
|
||||
...consecutiveProfiles(3550, 3571, "py311"),
|
||||
// 3.14 and 3.15 keep the 3.11 code layout; 3.14a1 magic 3608 adds slice
|
||||
// constants to marshal, which the reader gates by magic. Only magics checked
|
||||
// against real CPython are pinned: 3627 (3.14.4) and 3663 (3.15.0a8) were
|
||||
// read back from those interpreters; 3666 (3.15.2) was checked with real
|
||||
// 3.15.2 release bytes decoded by the 3.15.0a8 interpreter. Other
|
||||
// pre-release magics stay unpinned.
|
||||
...profiles([3627, 3663, 3666], "py311"),
|
||||
]);
|
||||
|
||||
export const pythonPycMarshalProfile = (
|
||||
@@ -160,6 +169,7 @@ const pythonConstSchema = z.discriminatedUnion("kind", [
|
||||
z.strictObject({ kind: z.literal("frozenset"), length: uint }),
|
||||
z.strictObject({ kind: z.literal("dict"), length: uint }),
|
||||
z.strictObject({ kind: z.literal("ellipsis") }),
|
||||
z.strictObject({ kind: z.literal("slice") }),
|
||||
z.strictObject({
|
||||
kind: z.literal("complex"),
|
||||
real: pythonFloatSchema,
|
||||
@@ -253,7 +263,7 @@ export const pythonPycHeaderSchema = z
|
||||
});
|
||||
});
|
||||
|
||||
/** Bounded CPython 3.7–3.13 pyc observation; marshal is walked, bytecode is not decompiled. */
|
||||
/** Bounded CPython 3.7–3.15 pyc observation; marshal is walked, bytecode is not decompiled. */
|
||||
export const pythonPycSchema = z
|
||||
.strictObject({
|
||||
artifact: z.strictObject({
|
||||
|
||||
Reference in new issue
Block a user