From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "struct" |
|---|
| subject | "Format:Marshal (Python)" |
|---|
| claim | "The fixed-size start of a marshalled CPython 3.11+ code object: the type byte ('c', usually with FLAG_REF: E3) and five int32 fields, 21 bytes, unaligned; the bytecode object (normally 's'|0x80 = F3 + int32 length) follows at offset 21." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:Marshal (Python)" |
|---|
| observed_in | |
|---|
|
|---|
| data | | name | "marshal_code_prefix_311" |
|---|
| size | 21 |
|---|
| alignment | 1 |
|---|
| fields | | offset | "0x0" |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "type" |
|---|
| notes | "0x63 'c', 0xE3 with FLAG_REF" |
|---|
|
| offset | "0x1" |
|---|
| size | 4 |
|---|
| type | "int32_t" |
|---|
| name | "argcount" |
|---|
|
| offset | "0x5" |
|---|
| size | 4 |
|---|
| type | "int32_t" |
|---|
| name | "posonlyargcount" |
|---|
|
| offset | "0x9" |
|---|
| size | 4 |
|---|
| type | "int32_t" |
|---|
| name | "kwonlyargcount" |
|---|
|
| offset | "0xD" |
|---|
| size | 4 |
|---|
| type | "int32_t" |
|---|
| name | "stacksize" |
|---|
|
| offset | "0x11" |
|---|
| size | 4 |
|---|
| type | "int32_t" |
|---|
| name | "flags" |
|---|
| notes | "CO_* flags, see the code flags enum" |
|---|
|
|
|---|
| endianness | "little" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "argcount, posonlyargcount, kwonlyargcount, stacksize, flags = r_long(p) each, then code = r_object(p)" |
|---|
| repo | "https://github.com/python/cpython" |
|---|
| commit | "010bebbf9fd12bba1e3f40bdbddacd51a9c2bf20" |
|---|
| path | "Python/marshal.c" |
|---|
| lines | "1849-1866" |
|---|
|
| type | "runtime_test" |
|---|
| detail | "3.11.15 pyc at offset 16: E3 00000000 00000000 00000000 04000000 00000000 F3 94000000 97 00 (stacksize 4, 148-byte bytecode starting with RESUME)" |
|---|
|
| type | "source" |
|---|
| detail | "w_long emits x&0xff, x>>8, x>>16, x>>24 in that order; w_get_uint32 reads b[0] | b[1]<<8 | b[2]<<16 | b[3]<<24" |
|---|
| repo | "https://github.com/python/cpython" |
|---|
| commit | "010bebbf9fd12bba1e3f40bdbddacd51a9c2bf20" |
|---|
| path | "Python/marshal.c" |
|---|
| lines | "204-219" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "code_object_prefix (3.11+)" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T05:12:30.074Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T06:25:40.316Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read Python/marshal.c at 010bebbf9fd1 lines 1818-1866 (TYPE_CODE): five r_long reads argcount, posonlyargcount, kwonlyargcount, stacksize, flags, then r_object for code; 1 type byte + 5*4 = 21 bytes, no nlocals field (removed in 3.11). Matches." |
|---|
|
|
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T12:50:20.934Z" |
|---|
| summary | "Byte order set: w_long writes bytes low first (little-endian)" |
|---|
| changed | |
|---|
|
|
|---|