From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "behavior" |
|---|
| subject | "Format:Marshal (Python)" |
|---|
| claim | "co_exceptiontable of CPython 3.11+ is a list of entries of four varints: start, size, target and (depth << 1) | lasti, with offsets and sizes in 2-byte code units. The first byte of each entry has bit 7 set; each varint is 6-bit chunks MOST significant first with bit 6 = more chunks, the opposite order from the location table." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:Marshal (Python)" |
|---|
| observed_in | |
|---|
|
|---|
| data | | effect | "handler entries (start, end = start + size, target, stack depth, push lasti)" |
|---|
| condition | "CPython 3.11 and later (zero-cost exceptions; earlier versions use SETUP_* opcodes and have no table)" |
|---|
| test_vectors | | input | "82 04 07 00" |
|---|
| expected | "start 2, end 6, target 7 (code units; byte offsets 4, 12, 14), depth 0, lasti False" |
|---|
|
| input | "87 09 13 03" |
|---|
| expected | "start 7, end 16, target 19, depth 1, lasti True" |
|---|
|
| input | "documentation example 94 08 41 24 06" |
|---|
| expected | "start 20, end 28, target 100, depth 3, lasti False" |
|---|
|
|
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "_parse_varint: val <<= 6 then |= b & 63 (MSB first); _parse_exception_table multiplies by 2 for byte offsets" |
|---|
| repo | "https://github.com/python/cpython" |
|---|
| commit | "010bebbf9fd12bba1e3f40bdbddacd51a9c2bf20" |
|---|
| path | "Lib/dis.py" |
|---|
| lines | "741-764" |
|---|
|
| type | "documentation" |
|---|
| detail | "Format of the exception table, with the 5-byte example" |
|---|
| repo | "https://github.com/python/cpython" |
|---|
| commit | "010bebbf9fd12bba1e3f40bdbddacd51a9c2bf20" |
|---|
| path | "InternalDocs/exception_handling.md" |
|---|
| lines | "106-176" |
|---|
|
| type | "runtime_test" |
|---|
| detail | "An independent decoder reproduces dis._parse_exception_table for all 15441 (3.11.15) and 138314 (3.12.8) exception entries in the stdlib pycs; vectors from a try/except function compiled by 3.12.8" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Exception table encoding (3.11+)" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T05:22:09.189Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T09:29:00.476Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read cpython Lib/dis.py _parse_varint/_parse_exception_table (735-764) and InternalDocs/exception_handling.md (106-176) at 010bebb: start,size,target,depth<<1|lasti, 2-byte code units, MSB-first 6-bit chunks with bit 6 extend, bit 7 on the first byte of an entry." |
|---|
|
|
|---|